# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
165502 | 2019-11-27T11:40:49 Z | egekabas | Vudu (COCI15_vudu) | C++14 | 565 ms | 16160 KB |
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<ll, ll> pii; typedef pair<ld, ld> pld; ll n, p; int a[1000009]; ll cur = 1; int bit[1000009]; vector<ll> v; void upd(ll idx){ while(idx > 0){ bit[idx]++; idx -= idx&(-idx); } } ll get(ll idx){ ll ret = 0; while(idx <= cur+2){ ret += bit[idx]; idx += idx&(-idx); } return ret; } int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); scanf("%lld", &n); for(ll i = 0; i < n; ++i){ scanf("%d", &a[i]); } scanf("%lld", &p); for(ll i = 0; i < n; ++i){ a[i] -= p; } ll add = 0; for(ll i = 0; i < n; ++i){ //s.insert(-a[i]+add); add -= a[i]; v.pb(a[i]+add); } sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end())-v.begin()); ll ans = 0; add = 0; for(ll i = 0; i < n; ++i){ if(a[i] >= 0){ ++ans; } ans += get(1+lower_bound(v.begin(), v.end(), -a[i]+add)-v.begin()); add -= a[i]; upd(1+lower_bound(v.begin(), v.end(), a[i]+add)-v.begin()); } printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 504 KB | Output isn't correct |
2 | Incorrect | 4 ms | 504 KB | Output isn't correct |
3 | Incorrect | 4 ms | 520 KB | Output isn't correct |
4 | Incorrect | 565 ms | 15600 KB | Output isn't correct |
5 | Incorrect | 301 ms | 10812 KB | Output isn't correct |
6 | Incorrect | 456 ms | 13892 KB | Output isn't correct |
7 | Incorrect | 468 ms | 14436 KB | Output isn't correct |
8 | Incorrect | 423 ms | 12528 KB | Output isn't correct |
9 | Incorrect | 525 ms | 16160 KB | Output isn't correct |
10 | Incorrect | 453 ms | 14024 KB | Output isn't correct |