# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976957 | SeenSiravit | Vudu (COCI15_vudu) | C++14 | 1058 ms | 26288 KiB |
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<bits/stdc++.h>
#define ll long long
using namespace std;
const int mxN = 1e6 + 5;
int n;
ll a[mxN] , b[mxN];
ll p;
int main(){
cin>> n;
for(int i=1;i<=n;i++) cin>> a[i] , a[i] += a[i-1];
// for(int i=1;i<=n;i++) cout<< a[i] << " ";
// cout<< "\n";
cin>> p;
for(int i=1;i<=n;i++) b[i] = a[i] - p*i;
// for(int i=1;i<=n;i++) cout<< b[i] << " ";
// cout<< "\n\n";
vector<ll> v;
ll ans = 0;
for(int i=1;i<=n;i++){
// cout<< i << " : ";
// for(auto val : v) cout<< val << " " ;
int cnt = upper_bound(v.begin() , v.end() , b[i]) - v.begin();
// cout<< "\ncnt = " << cnt << " ";
if(a[i]-a[i-1] >= p) cnt++;
// cout<< cnt << "\n\n";
ans += cnt;
v.push_back(b[i-1]);
sort(v.begin() , v.end());
}
cout<< ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |