#include "ricehub.h"
#include <bits/stdc++.h>
#define d1(x) cerr<<#x<<":"<<x<<endl;
#define d2(x,y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define d3(x,y,z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
const int maxN = (int) 1e5 + 5 ;
int ar[maxN],ans;
using namespace std;
vector <int> v,vec;
int n;
int get(int val,long long B) {
v.clear();
for (int i = 1 ; i <= n ; i++)
v.push_back(abs(ar[i] - val));
sort(v.begin(),v.end());
int cnt = 0;
for (int i = 0 ; i < n ; i++) {
if (v[i] > B) return cnt;
cnt++;
B -= v[i];
}
return cnt;
}
int besthub(int R, int L, int X[], long long B) {
n = R;
for (int i = R ; i >= 1 ; i--)
ar[i] = X[i - 1];
for (int i = 1 ,last = -1; i <= R ; i++) {
if (last == ar[i]) continue;
last = ar[i];
vec.push_back(ar[i]);
}
for (auto i : vec)
ans = max(ans ,get(i,B));
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
692 KB |
Output is correct |
2 |
Correct |
2 ms |
808 KB |
Output is correct |
3 |
Correct |
2 ms |
828 KB |
Output is correct |
4 |
Correct |
2 ms |
832 KB |
Output is correct |
5 |
Correct |
2 ms |
836 KB |
Output is correct |
6 |
Correct |
2 ms |
840 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
864 KB |
Output is correct |
12 |
Correct |
2 ms |
868 KB |
Output is correct |
13 |
Correct |
2 ms |
876 KB |
Output is correct |
14 |
Correct |
2 ms |
876 KB |
Output is correct |
15 |
Correct |
3 ms |
880 KB |
Output is correct |
16 |
Correct |
2 ms |
884 KB |
Output is correct |
17 |
Correct |
2 ms |
888 KB |
Output is correct |
18 |
Correct |
2 ms |
892 KB |
Output is correct |
19 |
Correct |
2 ms |
900 KB |
Output is correct |
20 |
Correct |
3 ms |
900 KB |
Output is correct |
21 |
Correct |
2 ms |
904 KB |
Output is correct |
22 |
Correct |
2 ms |
908 KB |
Output is correct |
23 |
Correct |
9 ms |
912 KB |
Output is correct |
24 |
Correct |
8 ms |
924 KB |
Output is correct |
25 |
Correct |
10 ms |
924 KB |
Output is correct |
26 |
Correct |
7 ms |
928 KB |
Output is correct |
27 |
Correct |
9 ms |
932 KB |
Output is correct |
28 |
Correct |
7 ms |
936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1040 KB |
Output is correct |
2 |
Correct |
2 ms |
1040 KB |
Output is correct |
3 |
Correct |
30 ms |
1040 KB |
Output is correct |
4 |
Correct |
21 ms |
1040 KB |
Output is correct |
5 |
Correct |
2 ms |
1040 KB |
Output is correct |
6 |
Correct |
3 ms |
1040 KB |
Output is correct |
7 |
Correct |
3 ms |
1040 KB |
Output is correct |
8 |
Correct |
4 ms |
1040 KB |
Output is correct |
9 |
Correct |
6 ms |
1040 KB |
Output is correct |
10 |
Correct |
7 ms |
1040 KB |
Output is correct |
11 |
Correct |
23 ms |
1040 KB |
Output is correct |
12 |
Correct |
18 ms |
1180 KB |
Output is correct |
13 |
Correct |
25 ms |
1180 KB |
Output is correct |
14 |
Correct |
25 ms |
1180 KB |
Output is correct |
15 |
Correct |
6 ms |
1180 KB |
Output is correct |
16 |
Correct |
8 ms |
1180 KB |
Output is correct |
17 |
Correct |
16 ms |
1188 KB |
Output is correct |
18 |
Correct |
16 ms |
1188 KB |
Output is correct |
19 |
Correct |
26 ms |
1188 KB |
Output is correct |
20 |
Correct |
33 ms |
1228 KB |
Output is correct |
21 |
Correct |
30 ms |
1264 KB |
Output is correct |
22 |
Correct |
24 ms |
1288 KB |
Output is correct |
23 |
Correct |
771 ms |
1328 KB |
Output is correct |
24 |
Correct |
682 ms |
1468 KB |
Output is correct |
25 |
Correct |
829 ms |
1468 KB |
Output is correct |
26 |
Correct |
823 ms |
1672 KB |
Output is correct |
27 |
Correct |
729 ms |
1672 KB |
Output is correct |
28 |
Correct |
774 ms |
1672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1069 ms |
1952 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |