답안 #715710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715710 2023-03-27T15:16:36 Z North1304 Pilot (NOI19_pilot) C++17
89 / 100
1000 ms 47036 KB
#include <bits/stdc++.h>
using namespace std;
int n,m;
pair<int,int> a[1000001],q[1000001];
set<pair<int,int> > s;
long long ans[1000001],now;
void add(int x) {
    auto it = s.lower_bound({x, INT_MAX});
    int ll = x , rr = x;
    long long l = 0,r = 0;
    if (it!=s.begin()){
        it--;
        if(it->second==x-1) {
            l = it->second-it->first+1;
            ll = it->first;
            it = s.erase(it);
        }
        else it++;
        }
    if (it!=s.end()) {
        if(it->first==x+1) {
            r = it->second-it->first+1;
            rr = it->second;
            s.erase(it); 
        }
    }
    now += (l+1) * (r+1);
    s.insert({ll,rr});
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for(int i=1;i<=n;i++) cin >> a[i].first, a[i].second = i;
    for(int i=1;i<=m;i++) cin >> q[i].first, q[i].second = i;
    sort(a+1, a+n+1);
    sort(q+1, q+m+1);
    int x = 1,y = 1;
    while (y<=m) {
        while(x<=n and a[x].first<=q[y].first) {
            add(a[x].second);
            x++;
        }
        ans[q[y].second] = now;
        y++;
    }
    for(int i=1;i<=m;i++) cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 2896 KB Output is correct
2 Correct 65 ms 2872 KB Output is correct
3 Correct 48 ms 2704 KB Output is correct
4 Correct 44 ms 2680 KB Output is correct
5 Correct 46 ms 2576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 4580 KB Output is correct
2 Correct 39 ms 4704 KB Output is correct
3 Correct 42 ms 4684 KB Output is correct
4 Correct 36 ms 4660 KB Output is correct
5 Correct 35 ms 4548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 4660 KB Output is correct
2 Correct 44 ms 4636 KB Output is correct
3 Correct 38 ms 4812 KB Output is correct
4 Correct 38 ms 4712 KB Output is correct
5 Correct 40 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 58 ms 2896 KB Output is correct
12 Correct 65 ms 2872 KB Output is correct
13 Correct 48 ms 2704 KB Output is correct
14 Correct 44 ms 2680 KB Output is correct
15 Correct 46 ms 2576 KB Output is correct
16 Correct 42 ms 2672 KB Output is correct
17 Correct 28 ms 2796 KB Output is correct
18 Correct 22 ms 2204 KB Output is correct
19 Correct 16 ms 1848 KB Output is correct
20 Correct 32 ms 2760 KB Output is correct
21 Correct 45 ms 2644 KB Output is correct
22 Correct 31 ms 2716 KB Output is correct
23 Correct 24 ms 2508 KB Output is correct
24 Correct 20 ms 2320 KB Output is correct
25 Correct 33 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 58 ms 2896 KB Output is correct
27 Correct 65 ms 2872 KB Output is correct
28 Correct 48 ms 2704 KB Output is correct
29 Correct 44 ms 2680 KB Output is correct
30 Correct 46 ms 2576 KB Output is correct
31 Correct 35 ms 4580 KB Output is correct
32 Correct 39 ms 4704 KB Output is correct
33 Correct 42 ms 4684 KB Output is correct
34 Correct 36 ms 4660 KB Output is correct
35 Correct 35 ms 4548 KB Output is correct
36 Correct 38 ms 4660 KB Output is correct
37 Correct 44 ms 4636 KB Output is correct
38 Correct 38 ms 4812 KB Output is correct
39 Correct 38 ms 4712 KB Output is correct
40 Correct 40 ms 4940 KB Output is correct
41 Correct 42 ms 2672 KB Output is correct
42 Correct 28 ms 2796 KB Output is correct
43 Correct 22 ms 2204 KB Output is correct
44 Correct 16 ms 1848 KB Output is correct
45 Correct 32 ms 2760 KB Output is correct
46 Correct 45 ms 2644 KB Output is correct
47 Correct 31 ms 2716 KB Output is correct
48 Correct 24 ms 2508 KB Output is correct
49 Correct 20 ms 2320 KB Output is correct
50 Correct 33 ms 2636 KB Output is correct
51 Correct 88 ms 5708 KB Output is correct
52 Correct 83 ms 5580 KB Output is correct
53 Correct 78 ms 5656 KB Output is correct
54 Correct 84 ms 5544 KB Output is correct
55 Correct 89 ms 5676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 58 ms 2896 KB Output is correct
27 Correct 65 ms 2872 KB Output is correct
28 Correct 48 ms 2704 KB Output is correct
29 Correct 44 ms 2680 KB Output is correct
30 Correct 46 ms 2576 KB Output is correct
31 Correct 35 ms 4580 KB Output is correct
32 Correct 39 ms 4704 KB Output is correct
33 Correct 42 ms 4684 KB Output is correct
34 Correct 36 ms 4660 KB Output is correct
35 Correct 35 ms 4548 KB Output is correct
36 Correct 38 ms 4660 KB Output is correct
37 Correct 44 ms 4636 KB Output is correct
38 Correct 38 ms 4812 KB Output is correct
39 Correct 38 ms 4712 KB Output is correct
40 Correct 40 ms 4940 KB Output is correct
41 Correct 42 ms 2672 KB Output is correct
42 Correct 28 ms 2796 KB Output is correct
43 Correct 22 ms 2204 KB Output is correct
44 Correct 16 ms 1848 KB Output is correct
45 Correct 32 ms 2760 KB Output is correct
46 Correct 45 ms 2644 KB Output is correct
47 Correct 31 ms 2716 KB Output is correct
48 Correct 24 ms 2508 KB Output is correct
49 Correct 20 ms 2320 KB Output is correct
50 Correct 33 ms 2636 KB Output is correct
51 Correct 88 ms 5708 KB Output is correct
52 Correct 83 ms 5580 KB Output is correct
53 Correct 78 ms 5656 KB Output is correct
54 Correct 84 ms 5544 KB Output is correct
55 Correct 89 ms 5676 KB Output is correct
56 Execution timed out 1050 ms 47036 KB Time limit exceeded
57 Halted 0 ms 0 KB -