#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
const int mxn = 2e5 + 100;
int n, k;
int prf[mxn];
int get(int l, int r) {
return prf[r] - (l ? prf[l - 1] : 0);
}
void init(int _k, std::vector<int> r) {
k = _k;
n = r.size();
for (int i = 0; i < n; i++) prf[i] = (i ? prf[i - 1] : 0) + r[i];
return;
}
// 1 > : -1 < : 0 ?
int compare_plants(int x, int y) {
if (x < y) {
int sum = get(x, y - 1);
if (abs(sum) == y - x) return sum / abs(sum);
}
else {
int sum = get(x, n - 1);
if (y) sum += get(0, y - 1);
if (abs(sum) == (n - x + y)) return sum / abs(sum);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |