Submission #1815305
Source Code Expand
#include "bits/stdc++.h" using namespace std; #define RESIDUE(u,v) (capacity[u][v] - flow[u][v]) #define RCOST(u,v) (cost[u][v] + h[u] - h[v]) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define LL long long #define SEGSIZE 262144 #define INPUT_SIZE 100000 //max segt //segt[best]->max value LL segt[SEGSIZE]; LL input[INPUT_SIZE]; int depth=0; int best=0; int start=0; int par(int i){ if(i==0) return -1; return (i-1)/2; } void update(int d,LL x){ int i=d+start; segt[i]=x; while(par(i)!=-1){ segt[par(i)]=max(segt[i],segt[(i+1)/2*4-1-i]); i=par(i); } i=0; while(i<start){ i=(segt[i]==segt[2*i+1])?2*i+1:2*i+2; } best=i-start; } void init(int n){ while((1<<depth)<n){ depth++; } start=(1<<depth)-1; REP(i,1<<(depth+1)){ if(i<start) segt[i]=0; else if(i<start+n) segt[i]=input[i-start]; else segt[i]=-LLONG_MAX; } FOR(i,start,start+n){ int tmp=i; while(par(tmp)!=-1){ segt[par(tmp)]=max(segt[tmp],segt[(tmp+1)/2*4-1-tmp]); tmp=par(tmp); } } int i=0; while(i<start){ i=(segt[i]==segt[2*i+1])?2*i+1:2*i+2; } best=i-start; } LL ans[100000]; int main(){ int n; cin>>n; REP(i,n) cin>>input[i]; init(n); REP(i,n) ans[i]=0; int charnow = best; while(segt[0]){ //cerr<<charnow<<" "<<best<<endl; if(charnow > best) charnow=best; ans[charnow]++; update(best,segt[best+start]-1); } REP(i,n) cout<<ans[i]<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Frequency |
User | penpenpen |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1619 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 4096 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | TLE | 2103 ms | 256 KB |
02.txt | TLE | 2103 ms | 512 KB |
03.txt | TLE | 2103 ms | 256 KB |
04.txt | TLE | 2103 ms | 256 KB |
05.txt | TLE | 2103 ms | 256 KB |
06.txt | TLE | 2103 ms | 256 KB |
07.txt | AC | 1079 ms | 256 KB |
08.txt | TLE | 2103 ms | 256 KB |
09.txt | TLE | 2103 ms | 640 KB |
10.txt | TLE | 2103 ms | 256 KB |
11.txt | TLE | 2103 ms | 3840 KB |
12.txt | TLE | 2103 ms | 3840 KB |
13.txt | TLE | 2103 ms | 3840 KB |
14.txt | TLE | 2103 ms | 3840 KB |
15.txt | TLE | 2103 ms | 3840 KB |
16.txt | TLE | 2103 ms | 3840 KB |
17.txt | TLE | 2103 ms | 3840 KB |
18.txt | TLE | 2103 ms | 3840 KB |
19.txt | AC | 184 ms | 4096 KB |
20.txt | TLE | 2103 ms | 3840 KB |
21.txt | TLE | 2103 ms | 256 KB |
22.txt | AC | 1 ms | 256 KB |
23.txt | TLE | 2103 ms | 256 KB |
24.txt | TLE | 2103 ms | 512 KB |
25.txt | TLE | 2103 ms | 256 KB |
26.txt | TLE | 2103 ms | 256 KB |
27.txt | TLE | 2103 ms | 256 KB |
28.txt | TLE | 2104 ms | 3840 KB |
29.txt | TLE | 2103 ms | 3840 KB |
30.txt | TLE | 2104 ms | 3840 KB |
31.txt | TLE | 2103 ms | 3840 KB |
32.txt | TLE | 2103 ms | 3840 KB |
33.txt | TLE | 2103 ms | 3840 KB |
34.txt | TLE | 2104 ms | 3840 KB |
35.txt | TLE | 2103 ms | 3840 KB |
36.txt | TLE | 2103 ms | 3840 KB |
37.txt | TLE | 2104 ms | 3840 KB |