Submission #976960

#TimeUsernameProblemLanguageResultExecution timeMemory
976960SeenSiravitVudu (COCI15_vudu)C++14
28 / 140
1071 ms16284 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(){ ios::sync_with_stdio(0),cin.tie(0); 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...