This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e9+7;
ll presum[MAXN],n;
void init(int k, std::vector<int> r) {
ll i;
n=(ll)r.size();
presum[0]=0;
for(i=1;i<=n;i++){
presum[i]=presum[i-1]+r[i-1];
}
return;
}
int compare_plants(int x, int y) {
x++; y++;
ll k = presum[y-1]-presum[x-1];
// cout<<"first"<<k<<"\n";
if(k==0){return 1; }
if(k==y-x){return -1; }
k = presum[n]-presum[y-1];
k += presum[x-1];
// cout<<"second "<<k<<endl;
if(k==0){return -1; }
if(k==n-(y-x)){return 1; }
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... |