# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335632 | 2020-12-13T11:37:07 Z | Joshc | Vudu (COCI15_vudu) | C++11 | 324 ms | 31796 KB |
#include <cstdio> #include <vector> #include <algorithm> using namespace std; #define ll long long #define f first #define s second ll l[1000001]; int bit[1000001], m[1000001]; int main() { ll 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<ll, 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) count++; m[arr[i].s] = count; } for (int i=n; i>=0; i--) { for (int j=m[i]; j<=n; j+=j&-j) bit[j]++; for (int j=m[i]-1; j>0; j-=j&-j) ans += bit[j]; } printf("%lld\n", n*(n+1)/2-ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 748 KB | Output is correct |
2 | Correct | 2 ms | 620 KB | Output is correct |
3 | Correct | 2 ms | 620 KB | Output is correct |
4 | Correct | 294 ms | 30644 KB | Output is correct |
5 | Correct | 167 ms | 21204 KB | Output is correct |
6 | Correct | 256 ms | 27188 KB | Output is correct |
7 | Correct | 259 ms | 28352 KB | Output is correct |
8 | Correct | 237 ms | 24628 KB | Output is correct |
9 | Correct | 324 ms | 31796 KB | Output is correct |
10 | Correct | 251 ms | 27636 KB | Output is correct |