# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219225 | gabrc52 | Vudu (COCI15_vudu) | C++14 | 1102 ms | 65540 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 <iostream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;
typedef long long ll;
const int MAXN=1e6;
int N;
int arr[MAXN];
int P;
indexed_multiset s;
ll ac[MAXN];
ll sum[MAXN];
ll dif[MAXN];
ll than;
ll ans;
void remove(ll val) {
s.erase(s.find_by_order(s.order_of_key(val)));
}
int countLowerOrEqual(ll val) {
return s.order_of_key(val+1);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>N;
for (int i=0; i<N; i++) {
cin>>arr[i];
}
cin>>P;
ac[0] = arr[0];
for (int i=1; i<N; i++) {
ac[i] = arr[i] + ac[i-1];
}
sum[0] = P;
dif[0] = sum[0] - ac[0];
for (int i=1; i<=N; i++) {
sum[i] = sum[i-1] + P;
dif[i] = sum[i] - ac[i];
};
for (int i=0; i<N; i++) {
s.insert(dif[i]);
}
than = 0;
ans += countLowerOrEqual(0);
for (int i=1; i<N; i++) {
remove(dif[i-1]);
than += P - arr[i-1];
ans += countLowerOrEqual(than);
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |