답안 #305560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305560 2020-09-23T14:00:49 Z nickmet2004 Exercise Deadlines (CCO20_day1problem2) C++11
25 / 25
158 ms 14200 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;
    long long 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

Main.cpp: In function 'int get(int)':
Main.cpp:14:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |     for(; i; i -= i & -i) sum += F[i]; return sum;
      |     ^~~
Main.cpp:14:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   14 |     for(; i; i -= i & -i) sum += F[i]; return sum;
      |                                        ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5120 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 6 ms 5120 KB Output is correct
5 Correct 5 ms 5120 KB Output is correct
6 Correct 5 ms 5120 KB Output is correct
7 Correct 7 ms 5248 KB Output is correct
8 Correct 6 ms 5168 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 5 ms 5248 KB Output is correct
11 Correct 6 ms 5280 KB Output is correct
12 Correct 6 ms 5248 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 6 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 5 ms 5120 KB Output is correct
18 Correct 5 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
20 Correct 6 ms 5120 KB Output is correct
21 Correct 6 ms 5120 KB Output is correct
22 Correct 6 ms 5120 KB Output is correct
23 Correct 6 ms 5120 KB Output is correct
24 Correct 7 ms 5120 KB Output is correct
25 Correct 7 ms 5120 KB Output is correct
26 Correct 6 ms 5120 KB Output is correct
27 Correct 5 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Correct 5 ms 5120 KB Output is correct
30 Correct 6 ms 5120 KB Output is correct
31 Correct 5 ms 5120 KB Output is correct
32 Correct 5 ms 5120 KB Output is correct
33 Correct 5 ms 5248 KB Output is correct
34 Correct 6 ms 5120 KB Output is correct
35 Correct 6 ms 5120 KB Output is correct
36 Correct 6 ms 5120 KB Output is correct
37 Correct 7 ms 5248 KB Output is correct
38 Correct 6 ms 5120 KB Output is correct
39 Correct 7 ms 5120 KB Output is correct
40 Correct 7 ms 5120 KB Output is correct
41 Correct 6 ms 5120 KB Output is correct
42 Correct 7 ms 5120 KB Output is correct
43 Correct 6 ms 5120 KB Output is correct
44 Correct 5 ms 4992 KB Output is correct
45 Correct 4 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5120 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 6 ms 5120 KB Output is correct
5 Correct 5 ms 5120 KB Output is correct
6 Correct 5 ms 5120 KB Output is correct
7 Correct 7 ms 5248 KB Output is correct
8 Correct 6 ms 5168 KB Output is correct
9 Correct 6 ms 5248 KB Output is correct
10 Correct 5 ms 5248 KB Output is correct
11 Correct 6 ms 5280 KB Output is correct
12 Correct 6 ms 5248 KB Output is correct
13 Correct 6 ms 5120 KB Output is correct
14 Correct 6 ms 5120 KB Output is correct
15 Correct 6 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 5 ms 5120 KB Output is correct
18 Correct 5 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
20 Correct 6 ms 5120 KB Output is correct
21 Correct 6 ms 5120 KB Output is correct
22 Correct 6 ms 5120 KB Output is correct
23 Correct 6 ms 5120 KB Output is correct
24 Correct 7 ms 5120 KB Output is correct
25 Correct 7 ms 5120 KB Output is correct
26 Correct 6 ms 5120 KB Output is correct
27 Correct 5 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Correct 5 ms 5120 KB Output is correct
30 Correct 6 ms 5120 KB Output is correct
31 Correct 5 ms 5120 KB Output is correct
32 Correct 5 ms 5120 KB Output is correct
33 Correct 5 ms 5248 KB Output is correct
34 Correct 6 ms 5120 KB Output is correct
35 Correct 6 ms 5120 KB Output is correct
36 Correct 6 ms 5120 KB Output is correct
37 Correct 7 ms 5248 KB Output is correct
38 Correct 6 ms 5120 KB Output is correct
39 Correct 7 ms 5120 KB Output is correct
40 Correct 7 ms 5120 KB Output is correct
41 Correct 6 ms 5120 KB Output is correct
42 Correct 7 ms 5120 KB Output is correct
43 Correct 6 ms 5120 KB Output is correct
44 Correct 5 ms 4992 KB Output is correct
45 Correct 4 ms 4992 KB Output is correct
46 Correct 141 ms 10488 KB Output is correct
47 Correct 142 ms 11892 KB Output is correct
48 Correct 102 ms 11924 KB Output is correct
49 Correct 121 ms 11896 KB Output is correct
50 Correct 132 ms 11764 KB Output is correct
51 Correct 116 ms 11888 KB Output is correct
52 Correct 140 ms 14072 KB Output is correct
53 Correct 119 ms 14072 KB Output is correct
54 Correct 98 ms 14072 KB Output is correct
55 Correct 69 ms 14200 KB Output is correct
56 Correct 99 ms 14072 KB Output is correct
57 Correct 100 ms 14068 KB Output is correct
58 Correct 153 ms 11896 KB Output is correct
59 Correct 131 ms 12024 KB Output is correct
60 Correct 129 ms 11896 KB Output is correct
61 Correct 103 ms 11896 KB Output is correct
62 Correct 72 ms 11896 KB Output is correct
63 Correct 95 ms 11896 KB Output is correct
64 Correct 138 ms 11896 KB Output is correct
65 Correct 124 ms 11768 KB Output is correct
66 Correct 107 ms 11768 KB Output is correct
67 Correct 113 ms 11768 KB Output is correct
68 Correct 126 ms 11896 KB Output is correct
69 Correct 147 ms 11768 KB Output is correct
70 Correct 135 ms 11852 KB Output is correct
71 Correct 137 ms 11768 KB Output is correct
72 Correct 127 ms 11768 KB Output is correct
73 Correct 118 ms 11768 KB Output is correct
74 Correct 89 ms 11896 KB Output is correct
75 Correct 130 ms 11896 KB Output is correct
76 Correct 90 ms 10360 KB Output is correct
77 Correct 72 ms 10088 KB Output is correct
78 Correct 61 ms 14072 KB Output is correct
79 Correct 71 ms 11896 KB Output is correct
80 Correct 90 ms 10360 KB Output is correct
81 Correct 75 ms 10224 KB Output is correct
82 Correct 65 ms 14072 KB Output is correct
83 Correct 66 ms 11880 KB Output is correct
84 Correct 142 ms 11912 KB Output is correct
85 Correct 158 ms 12024 KB Output is correct
86 Correct 130 ms 11896 KB Output is correct
87 Correct 106 ms 10744 KB Output is correct
88 Correct 155 ms 12024 KB Output is correct