#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
typedef long long ll;
int n, k;
int arr[200002];
int sum[200002];
void init(int _k, vector<int> r) {
n = (int)r.size();
k = _k;
for(int i=1; i<=n; i++) arr[i] = r[i-1];
for(int i=1; i<=n; i++) sum[i] = sum[i-1] + arr[i];
}
int compare_plants(int x, int y) {
x++, y++;
if(sum[y-1] - sum[x-1] == (y-1) - (x-1)) return -1;
if(sum[y-1] - sum[x-1] == 0) return 1;
if(sum[x-1] == x-1 && sum[n] - sum[y-1] == n-(y-1)) return 1;
if(!sum[x-1] && sum[n] == sum[y-1]) return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
57 ms |
4096 KB |
Output is correct |
7 |
Correct |
66 ms |
5556 KB |
Output is correct |
8 |
Correct |
93 ms |
8660 KB |
Output is correct |
9 |
Correct |
92 ms |
8660 KB |
Output is correct |
10 |
Correct |
90 ms |
8664 KB |
Output is correct |
11 |
Correct |
95 ms |
8772 KB |
Output is correct |
12 |
Correct |
113 ms |
8668 KB |
Output is correct |
13 |
Correct |
84 ms |
8664 KB |
Output is correct |
14 |
Correct |
83 ms |
8620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
57 ms |
4096 KB |
Output is correct |
7 |
Correct |
66 ms |
5556 KB |
Output is correct |
8 |
Correct |
93 ms |
8660 KB |
Output is correct |
9 |
Correct |
92 ms |
8660 KB |
Output is correct |
10 |
Correct |
90 ms |
8664 KB |
Output is correct |
11 |
Correct |
95 ms |
8772 KB |
Output is correct |
12 |
Correct |
113 ms |
8668 KB |
Output is correct |
13 |
Correct |
84 ms |
8664 KB |
Output is correct |
14 |
Correct |
83 ms |
8620 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |