#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int resp = 0;
for (int i = 1; i <= R; i++)
{
int p = i; int q = i+1;
int sum = 0; int respi = 0;
while (p >= 1 && q <= R)
{
int desq = abs(X[i] - X[p]); int ddir = abs(X[q] - X[i]);
if (desq < ddir)
{
if (sum + desq > B) break;
sum += desq;
p--;
respi++;
}
else
{
if (sum + ddir > B) break;
sum += ddir;
q++;
respi++;
}
}
// cerr << i << " " << sum << " " << respi << '\n';
resp = max(resp, respi);
}
return resp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
2 ms |
216 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
428 KB |
Output is correct |
2 |
Correct |
6 ms |
468 KB |
Output is correct |
3 |
Execution timed out |
1088 ms |
1740 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |