# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335631 | 2020-12-13T11:34:14 Z | Joshc | Vudu (COCI15_vudu) | C++11 | 322 ms | 27592 KB |
#include <cstdio> #include <vector> #include <algorithm> using namespace std; #define f first #define s second long long int l[1000001]; int bit[1000001], m[1000001]; int main() { long long int n, p, count=1, ans=0; scanf("%lld", &n); for (int i=1; i<=n; i++) scanf("%lld", &l[i]); scanf("%lld", &p); l[0] = 0; for (int i=1; i<=n; i++) l[i] = l[i-1]+l[i]-p; vector<pair<int, int> > arr; for (int i=0; i<=n; i++) arr.emplace_back(l[i], i); sort(arr.begin(), arr.end()); m[arr[0].s] = 1; for (int i=1; i<=n; i++) { if (arr[i].f != arr[i-1].f) m[arr[i].s] = ++count; else m[arr[i].s] = count; } for (int i=n; i>=0; i--) { for (long long int j=m[i]; j<=n; j+=j&-j) bit[j]++; for (long long int j=m[i]-1; j>0; j-=j&-j) ans += bit[j]; } printf("%lld\n", n*(n+1)/2-ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 516 KB | Output is correct |
4 | Incorrect | 315 ms | 25032 KB | Output isn't correct |
5 | Incorrect | 201 ms | 13512 KB | Output isn't correct |
6 | Incorrect | 282 ms | 20524 KB | Output isn't correct |
7 | Incorrect | 287 ms | 21340 KB | Output isn't correct |
8 | Incorrect | 269 ms | 18504 KB | Output isn't correct |
9 | Incorrect | 322 ms | 27592 KB | Output isn't correct |
10 | Incorrect | 289 ms | 20808 KB | Output isn't correct |