Submission #976957

#TimeUsernameProblemLanguageResultExecution timeMemory
976957SeenSiravitVudu (COCI15_vudu)C++14
28 / 140
1058 ms26288 KiB
#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 timeMemoryGrader output
Fetching results...