#include "plants.h"
using namespace std;
vector<int> sum;
int sm = 0;
int n;
void init(int k, vector<int> r) {
n = r.size();
sum.resize(n);
sum[0] = r[0];
sm += r[0];
for (int i = 1; i < n; ++i) {
sum[i] = sum[i-1] + r[i];
sm += r[i];
}
}
int compare_plants(int x, int y) {
if (x > y) swap(x, y);
int k = sum[y-1];
if (x != 0) k -= sum[x-1];
if (k == y - x) return -1;
if (k == 0) return 1;
k = sm - k;
if (k == (n - y) + x) return 1;
if (k == 0) 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 |
0 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 |
62 ms |
3956 KB |
Output is correct |
7 |
Correct |
76 ms |
5384 KB |
Output is correct |
8 |
Correct |
101 ms |
7876 KB |
Output is correct |
9 |
Correct |
100 ms |
7852 KB |
Output is correct |
10 |
Correct |
101 ms |
7880 KB |
Output is correct |
11 |
Correct |
98 ms |
7856 KB |
Output is correct |
12 |
Correct |
93 ms |
7880 KB |
Output is correct |
13 |
Correct |
93 ms |
7984 KB |
Output is correct |
14 |
Correct |
98 ms |
7872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
0 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 |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
208 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 |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
62 ms |
3956 KB |
Output is correct |
7 |
Correct |
76 ms |
5384 KB |
Output is correct |
8 |
Correct |
101 ms |
7876 KB |
Output is correct |
9 |
Correct |
100 ms |
7852 KB |
Output is correct |
10 |
Correct |
101 ms |
7880 KB |
Output is correct |
11 |
Correct |
98 ms |
7856 KB |
Output is correct |
12 |
Correct |
93 ms |
7880 KB |
Output is correct |
13 |
Correct |
93 ms |
7984 KB |
Output is correct |
14 |
Correct |
98 ms |
7872 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |