# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
305556 | 2020-09-23T13:59:16 Z | nickmet2004 | Exercise Deadlines (CCO20_day1problem2) | C++11 | 124 ms | 11892 KB |
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n , d[N]; int F[N]; vector<int> E[N]; void upd(int i , int v){ for(; i <=n; i += i & -i) F[i]+=v; } int get(int i){ int sum = 0; for(; i; i -= i & -i) sum += F[i]; return sum; } int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; ++i) cin >> d[i] ,E[d[i]].emplace_back(i); sort(d+ 1 , d + n + 1); for(int i=1; i<= n; ++i) if(d[i] < i){cout << -1; return 0;} for(int i = 1; i <= n; ++i) upd(i , 1); priority_queue<int> pq; int ans =0; for(int i = n; i; --i){ for(int x : E[i]) pq.push(x); int a= pq.top(); pq.pop(); upd(n - a + 1 ,-1); ans += get(n - a + 1); }cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5376 KB | Output is correct |
2 | Correct | 6 ms | 5248 KB | Output is correct |
3 | Correct | 7 ms | 5248 KB | Output is correct |
4 | Correct | 6 ms | 5248 KB | Output is correct |
5 | Correct | 6 ms | 5248 KB | Output is correct |
6 | Correct | 6 ms | 5248 KB | Output is correct |
7 | Correct | 6 ms | 5248 KB | Output is correct |
8 | Correct | 5 ms | 5248 KB | Output is correct |
9 | Correct | 5 ms | 5248 KB | Output is correct |
10 | Correct | 5 ms | 5248 KB | Output is correct |
11 | Correct | 5 ms | 5248 KB | Output is correct |
12 | Correct | 5 ms | 5248 KB | Output is correct |
13 | Correct | 6 ms | 5248 KB | Output is correct |
14 | Correct | 6 ms | 5248 KB | Output is correct |
15 | Correct | 5 ms | 5248 KB | Output is correct |
16 | Correct | 6 ms | 5248 KB | Output is correct |
17 | Correct | 5 ms | 5248 KB | Output is correct |
18 | Correct | 6 ms | 5248 KB | Output is correct |
19 | Correct | 7 ms | 5248 KB | Output is correct |
20 | Correct | 6 ms | 5248 KB | Output is correct |
21 | Correct | 5 ms | 5248 KB | Output is correct |
22 | Correct | 6 ms | 5248 KB | Output is correct |
23 | Correct | 6 ms | 5248 KB | Output is correct |
24 | Correct | 7 ms | 5248 KB | Output is correct |
25 | Correct | 6 ms | 5248 KB | Output is correct |
26 | Correct | 6 ms | 5248 KB | Output is correct |
27 | Correct | 6 ms | 5248 KB | Output is correct |
28 | Correct | 6 ms | 5248 KB | Output is correct |
29 | Correct | 6 ms | 5248 KB | Output is correct |
30 | Correct | 6 ms | 5248 KB | Output is correct |
31 | Correct | 6 ms | 5120 KB | Output is correct |
32 | Correct | 6 ms | 5376 KB | Output is correct |
33 | Correct | 5 ms | 5248 KB | Output is correct |
34 | Correct | 5 ms | 5248 KB | Output is correct |
35 | Correct | 5 ms | 5120 KB | Output is correct |
36 | Correct | 5 ms | 5248 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5248 KB | Output is correct |
39 | Correct | 6 ms | 5248 KB | Output is correct |
40 | Correct | 5 ms | 5248 KB | Output is correct |
41 | Correct | 5 ms | 5120 KB | Output is correct |
42 | Correct | 6 ms | 5248 KB | Output is correct |
43 | Correct | 6 ms | 5120 KB | Output is correct |
44 | Correct | 4 ms | 4992 KB | Output is correct |
45 | Correct | 4 ms | 4992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5376 KB | Output is correct |
2 | Correct | 6 ms | 5248 KB | Output is correct |
3 | Correct | 7 ms | 5248 KB | Output is correct |
4 | Correct | 6 ms | 5248 KB | Output is correct |
5 | Correct | 6 ms | 5248 KB | Output is correct |
6 | Correct | 6 ms | 5248 KB | Output is correct |
7 | Correct | 6 ms | 5248 KB | Output is correct |
8 | Correct | 5 ms | 5248 KB | Output is correct |
9 | Correct | 5 ms | 5248 KB | Output is correct |
10 | Correct | 5 ms | 5248 KB | Output is correct |
11 | Correct | 5 ms | 5248 KB | Output is correct |
12 | Correct | 5 ms | 5248 KB | Output is correct |
13 | Correct | 6 ms | 5248 KB | Output is correct |
14 | Correct | 6 ms | 5248 KB | Output is correct |
15 | Correct | 5 ms | 5248 KB | Output is correct |
16 | Correct | 6 ms | 5248 KB | Output is correct |
17 | Correct | 5 ms | 5248 KB | Output is correct |
18 | Correct | 6 ms | 5248 KB | Output is correct |
19 | Correct | 7 ms | 5248 KB | Output is correct |
20 | Correct | 6 ms | 5248 KB | Output is correct |
21 | Correct | 5 ms | 5248 KB | Output is correct |
22 | Correct | 6 ms | 5248 KB | Output is correct |
23 | Correct | 6 ms | 5248 KB | Output is correct |
24 | Correct | 7 ms | 5248 KB | Output is correct |
25 | Correct | 6 ms | 5248 KB | Output is correct |
26 | Correct | 6 ms | 5248 KB | Output is correct |
27 | Correct | 6 ms | 5248 KB | Output is correct |
28 | Correct | 6 ms | 5248 KB | Output is correct |
29 | Correct | 6 ms | 5248 KB | Output is correct |
30 | Correct | 6 ms | 5248 KB | Output is correct |
31 | Correct | 6 ms | 5120 KB | Output is correct |
32 | Correct | 6 ms | 5376 KB | Output is correct |
33 | Correct | 5 ms | 5248 KB | Output is correct |
34 | Correct | 5 ms | 5248 KB | Output is correct |
35 | Correct | 5 ms | 5120 KB | Output is correct |
36 | Correct | 5 ms | 5248 KB | Output is correct |
37 | Correct | 5 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5248 KB | Output is correct |
39 | Correct | 6 ms | 5248 KB | Output is correct |
40 | Correct | 5 ms | 5248 KB | Output is correct |
41 | Correct | 5 ms | 5120 KB | Output is correct |
42 | Correct | 6 ms | 5248 KB | Output is correct |
43 | Correct | 6 ms | 5120 KB | Output is correct |
44 | Correct | 4 ms | 4992 KB | Output is correct |
45 | Correct | 4 ms | 4992 KB | Output is correct |
46 | Incorrect | 124 ms | 11892 KB | Output isn't correct |
47 | Halted | 0 ms | 0 KB | - |