#include "plants.h"
#include "bits/stdc++.h"
using namespace std;
int n;
vector<int> pref;
void init(int k, vector<int> r) {
n = r.size();
pref.resize(n);
for(int i=0;i<n;i++){
if(i) pref[i] = pref[i - 1];
pref[i] += r[i];
}
return;
}
int get(int x, int y){
return pref[y] - (x ? pref[x - 1] : 0);
}
int compare_plants(int x, int y) {
if(get(x, y - 1) == 0){
return 1;
}
if(get(x, y - 1) == y - x){
return -1;
}
int cnt = get(y, n - 1);
cnt += (x ? get(0, x - 1) : 0);
if(cnt == n - y + x){
return 1;
} if(cnt == 0) {
return -1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
41 ms |
4024 KB |
Output is correct |
7 |
Correct |
43 ms |
5472 KB |
Output is correct |
8 |
Correct |
64 ms |
7892 KB |
Output is correct |
9 |
Correct |
61 ms |
7896 KB |
Output is correct |
10 |
Correct |
58 ms |
7872 KB |
Output is correct |
11 |
Correct |
58 ms |
7880 KB |
Output is correct |
12 |
Correct |
57 ms |
7896 KB |
Output is correct |
13 |
Correct |
57 ms |
7892 KB |
Output is correct |
14 |
Correct |
56 ms |
7892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
41 ms |
4024 KB |
Output is correct |
7 |
Correct |
43 ms |
5472 KB |
Output is correct |
8 |
Correct |
64 ms |
7892 KB |
Output is correct |
9 |
Correct |
61 ms |
7896 KB |
Output is correct |
10 |
Correct |
58 ms |
7872 KB |
Output is correct |
11 |
Correct |
58 ms |
7880 KB |
Output is correct |
12 |
Correct |
57 ms |
7896 KB |
Output is correct |
13 |
Correct |
57 ms |
7892 KB |
Output is correct |
14 |
Correct |
56 ms |
7892 KB |
Output is correct |
15 |
Correct |
1 ms |
304 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |