#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define nd '\n'
using namespace std;
vector <int> prefix;
ll n=0;
void init (int k, vector <int> r){
n = r.size();
prefix.assign(n,0);
prefix[0]=r[0];
for (ll i=1; i<n; i++){
prefix[i] = prefix[i-1] + r[i];
}
return;
}
int compare_plants(int x, int y){
ll c = prefix[y-1];
if (x != 0) c-=prefix[x-1];
if (c == y-x) return -1;
else if (c == 0) return 1;
c = prefix[n-1] - prefix[y-1];
c+= prefix[x-1];
if (c == n-y+x) return 1;
else if (c == 0) return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
31 ms |
3060 KB |
Output is correct |
7 |
Correct |
37 ms |
3384 KB |
Output is correct |
8 |
Correct |
48 ms |
8044 KB |
Output is correct |
9 |
Correct |
55 ms |
7908 KB |
Output is correct |
10 |
Correct |
48 ms |
8044 KB |
Output is correct |
11 |
Correct |
50 ms |
8016 KB |
Output is correct |
12 |
Correct |
44 ms |
8020 KB |
Output is correct |
13 |
Correct |
47 ms |
7940 KB |
Output is correct |
14 |
Correct |
55 ms |
8016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
31 ms |
3060 KB |
Output is correct |
7 |
Correct |
37 ms |
3384 KB |
Output is correct |
8 |
Correct |
48 ms |
8044 KB |
Output is correct |
9 |
Correct |
55 ms |
7908 KB |
Output is correct |
10 |
Correct |
48 ms |
8044 KB |
Output is correct |
11 |
Correct |
50 ms |
8016 KB |
Output is correct |
12 |
Correct |
44 ms |
8020 KB |
Output is correct |
13 |
Correct |
47 ms |
7940 KB |
Output is correct |
14 |
Correct |
55 ms |
8016 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |