Submission #1025010

# Submission time Handle Problem Language Result Execution time Memory
1025010 2024-07-16T14:13:15 Z 12345678 Pilot (NOI19_pilot) C++17
89 / 100
1000 ms 110104 KB
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

using namespace std;

const int md=1e9+7;

int32_t main(){
    cin.tie(NULL)->sync_with_stdio(false);
    int n,q; cin >> n >> q;
    vector<int> he(n+1);
    vector<pair<int,int>> h(n+1),y(q+1);
    vector<int> pri(q+1);
    int ans=n*(n+1)/2;
    for(int i=1 ; i<=n ; i++) cin >> h[i].first,he[i]=h[i].first,h[i].second=i;
    for(int i=1 ; i<=q ; i++) cin >> y[i].first,y[i].second=i;
    sort(h.begin(),h.end());
    sort(he.begin(),he.end());
    sort(y.begin(),y.end());
    reverse(y.begin()+1,y.end());
    set<int> s;
    s.insert(0);
    s.insert(n+1);
    int id=n;
    for(int t=1 ; t<=q ; t++){
        int idx=upper_bound(he.begin(),he.end(),y[t].first)-he.begin();
        for(int i=idx ; i<=id ; i++){
            s.insert(h[i].second);
            auto itr=s.lower_bound(h[i].second);
            int now=*itr;
            itr--;
            int l=*itr;
            itr++;
            itr++;
            auto r=*itr;
            ans-=(now-l-1)*(r-now-1);
            ans-=r-l-1;
        }
        id=idx-1;
        pri[y[t].second]=ans;
    }
    for(int i=1 ; i<=q ; i++){
        cout << pri[i] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 456 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 456 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3164 KB Output is correct
2 Correct 18 ms 3268 KB Output is correct
3 Correct 20 ms 3160 KB Output is correct
4 Correct 17 ms 3080 KB Output is correct
5 Correct 18 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 11088 KB Output is correct
2 Correct 42 ms 11348 KB Output is correct
3 Correct 43 ms 11084 KB Output is correct
4 Correct 43 ms 11600 KB Output is correct
5 Correct 41 ms 11036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 11344 KB Output is correct
2 Correct 42 ms 11348 KB Output is correct
3 Correct 43 ms 11348 KB Output is correct
4 Correct 44 ms 11604 KB Output is correct
5 Correct 44 ms 11620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 18 ms 3164 KB Output is correct
12 Correct 18 ms 3268 KB Output is correct
13 Correct 20 ms 3160 KB Output is correct
14 Correct 17 ms 3080 KB Output is correct
15 Correct 18 ms 3164 KB Output is correct
16 Correct 28 ms 4432 KB Output is correct
17 Correct 37 ms 6236 KB Output is correct
18 Correct 48 ms 7372 KB Output is correct
19 Correct 41 ms 6996 KB Output is correct
20 Correct 31 ms 5452 KB Output is correct
21 Correct 17 ms 2904 KB Output is correct
22 Correct 28 ms 5048 KB Output is correct
23 Correct 39 ms 6484 KB Output is correct
24 Correct 38 ms 6480 KB Output is correct
25 Correct 38 ms 5460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 456 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 18 ms 3164 KB Output is correct
27 Correct 18 ms 3268 KB Output is correct
28 Correct 20 ms 3160 KB Output is correct
29 Correct 17 ms 3080 KB Output is correct
30 Correct 18 ms 3164 KB Output is correct
31 Correct 42 ms 11088 KB Output is correct
32 Correct 42 ms 11348 KB Output is correct
33 Correct 43 ms 11084 KB Output is correct
34 Correct 43 ms 11600 KB Output is correct
35 Correct 41 ms 11036 KB Output is correct
36 Correct 43 ms 11344 KB Output is correct
37 Correct 42 ms 11348 KB Output is correct
38 Correct 43 ms 11348 KB Output is correct
39 Correct 44 ms 11604 KB Output is correct
40 Correct 44 ms 11620 KB Output is correct
41 Correct 28 ms 4432 KB Output is correct
42 Correct 37 ms 6236 KB Output is correct
43 Correct 48 ms 7372 KB Output is correct
44 Correct 41 ms 6996 KB Output is correct
45 Correct 31 ms 5452 KB Output is correct
46 Correct 17 ms 2904 KB Output is correct
47 Correct 28 ms 5048 KB Output is correct
48 Correct 39 ms 6484 KB Output is correct
49 Correct 38 ms 6480 KB Output is correct
50 Correct 38 ms 5460 KB Output is correct
51 Correct 69 ms 11304 KB Output is correct
52 Correct 75 ms 11088 KB Output is correct
53 Correct 68 ms 11368 KB Output is correct
54 Correct 72 ms 11088 KB Output is correct
55 Correct 68 ms 11412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 456 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 18 ms 3164 KB Output is correct
27 Correct 18 ms 3268 KB Output is correct
28 Correct 20 ms 3160 KB Output is correct
29 Correct 17 ms 3080 KB Output is correct
30 Correct 18 ms 3164 KB Output is correct
31 Correct 42 ms 11088 KB Output is correct
32 Correct 42 ms 11348 KB Output is correct
33 Correct 43 ms 11084 KB Output is correct
34 Correct 43 ms 11600 KB Output is correct
35 Correct 41 ms 11036 KB Output is correct
36 Correct 43 ms 11344 KB Output is correct
37 Correct 42 ms 11348 KB Output is correct
38 Correct 43 ms 11348 KB Output is correct
39 Correct 44 ms 11604 KB Output is correct
40 Correct 44 ms 11620 KB Output is correct
41 Correct 28 ms 4432 KB Output is correct
42 Correct 37 ms 6236 KB Output is correct
43 Correct 48 ms 7372 KB Output is correct
44 Correct 41 ms 6996 KB Output is correct
45 Correct 31 ms 5452 KB Output is correct
46 Correct 17 ms 2904 KB Output is correct
47 Correct 28 ms 5048 KB Output is correct
48 Correct 39 ms 6484 KB Output is correct
49 Correct 38 ms 6480 KB Output is correct
50 Correct 38 ms 5460 KB Output is correct
51 Correct 69 ms 11304 KB Output is correct
52 Correct 75 ms 11088 KB Output is correct
53 Correct 68 ms 11368 KB Output is correct
54 Correct 72 ms 11088 KB Output is correct
55 Correct 68 ms 11412 KB Output is correct
56 Execution timed out 1039 ms 110104 KB Time limit exceeded
57 Halted 0 ms 0 KB -