# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
539175 | 2022-03-18T14:16:26 Z | astoria | 쌀 창고 (IOI11_ricehub) | C++14 | 15 ms | 2508 KB |
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { long long r,l,b; r=R; l=L; b=B; long long x[r]; for(long long i=0; i<r; i++) x[i] = X[i]; long long mx=0; long long td = 0; long long ll=0, rr=0; while(td<=b&&rr!=r-1){ if(td + x[rr+1]-x[0] <= b){ rr++; td+=(x[rr]-x[0]);} else break; //cout<<"KK"<<endl; } mx = max(mx, rr-ll+1); //cout<<ll<<' '<<rr<<endl; for(long long i=1; i<r; i++){ long long lef = i-ll, ri = rr-i+1; td += ((lef-ri)*(x[i]-x[i-1])); //cout<<td<<endl; while(td>b){ td-=(x[i]-x[ll]); ll++; assert(ll<=r-1); //cout<<"HEY"<<endl; } //if(i==2) cout<<td<<endl; while(td<=b&&rr!=r-1){ if(td + x[rr+1]-x[i] <= b){ rr++; td+=(x[rr]-x[i]);} else break; //cout<<"YK"<<endl; } //MAGIC while(abs(x[ll]-x[i]) >= abs(x[rr+1]-x[i]) && rr!=r-1){ td -= abs(x[ll]-x[i]); td+=abs(x[rr+1]-x[i]); ll++; rr++; } //MAGIC 2 if(rr==r-1){ while(td <= b && ll!=0){ if(td + abs(x[ll-1]-x[i]) <= b){ ll--; td+=abs(x[ll]-x[i]);} else break; } } mx=max(mx, rr-ll+1); //cout<<ll<<' '<<rr<<endl; } return mx; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 316 KB | Output is correct |
10 | Correct | 1 ms | 316 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 312 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 312 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 312 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 308 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 312 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 316 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 316 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 352 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 624 KB | Output is correct |
2 | Correct | 5 ms | 560 KB | Output is correct |
3 | Correct | 15 ms | 2508 KB | Output is correct |
4 | Correct | 13 ms | 2424 KB | Output is correct |
5 | Correct | 6 ms | 1120 KB | Output is correct |
6 | Correct | 5 ms | 1236 KB | Output is correct |
7 | Correct | 11 ms | 2244 KB | Output is correct |
8 | Correct | 11 ms | 2236 KB | Output is correct |
9 | Correct | 5 ms | 1096 KB | Output is correct |
10 | Correct | 6 ms | 1160 KB | Output is correct |
11 | Correct | 13 ms | 2504 KB | Output is correct |
12 | Correct | 13 ms | 2508 KB | Output is correct |
13 | Correct | 7 ms | 1216 KB | Output is correct |
14 | Correct | 7 ms | 1284 KB | Output is correct |
15 | Correct | 14 ms | 1940 KB | Output is correct |
16 | Correct | 11 ms | 1876 KB | Output is correct |
17 | Correct | 11 ms | 2292 KB | Output is correct |
18 | Correct | 13 ms | 2236 KB | Output is correct |
19 | Correct | 11 ms | 2352 KB | Output is correct |
20 | Correct | 12 ms | 2300 KB | Output is correct |