답안 #227337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227337 2020-04-27T04:37:54 Z Autoratch Pilot (NOI19_pilot) C++14
89 / 100
1000 ms 47224 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 1;

int n,m;
pair<int,int> a[N],q[N];
set<pair<int,int> > s;
long long ans[N],now;

void add(int x)
{
    auto it = s.lower_bound({x,INT_MAX});
    long long l = 0,r = 0,ll = x,rr = x;
    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+1LL)*(r+1LL);
    s.insert({ll,rr});
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    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(q+1,q+m+1),sort(a+1,a+n+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 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 2168 KB Output is correct
2 Correct 69 ms 3064 KB Output is correct
3 Correct 62 ms 2808 KB Output is correct
4 Correct 59 ms 2680 KB Output is correct
5 Correct 62 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3448 KB Output is correct
2 Correct 56 ms 4728 KB Output is correct
3 Correct 56 ms 4780 KB Output is correct
4 Correct 54 ms 4728 KB Output is correct
5 Correct 51 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 3448 KB Output is correct
2 Correct 53 ms 4728 KB Output is correct
3 Correct 57 ms 4856 KB Output is correct
4 Correct 54 ms 4856 KB Output is correct
5 Correct 56 ms 4984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 63 ms 2168 KB Output is correct
12 Correct 69 ms 3064 KB Output is correct
13 Correct 62 ms 2808 KB Output is correct
14 Correct 59 ms 2680 KB Output is correct
15 Correct 62 ms 2680 KB Output is correct
16 Correct 50 ms 2688 KB Output is correct
17 Correct 39 ms 2808 KB Output is correct
18 Correct 29 ms 2296 KB Output is correct
19 Correct 26 ms 1920 KB Output is correct
20 Correct 43 ms 2816 KB Output is correct
21 Correct 60 ms 2684 KB Output is correct
22 Correct 43 ms 2816 KB Output is correct
23 Correct 36 ms 2680 KB Output is correct
24 Correct 29 ms 2304 KB Output is correct
25 Correct 44 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 63 ms 2168 KB Output is correct
27 Correct 69 ms 3064 KB Output is correct
28 Correct 62 ms 2808 KB Output is correct
29 Correct 59 ms 2680 KB Output is correct
30 Correct 62 ms 2680 KB Output is correct
31 Correct 52 ms 3448 KB Output is correct
32 Correct 56 ms 4728 KB Output is correct
33 Correct 56 ms 4780 KB Output is correct
34 Correct 54 ms 4728 KB Output is correct
35 Correct 51 ms 4600 KB Output is correct
36 Correct 53 ms 3448 KB Output is correct
37 Correct 53 ms 4728 KB Output is correct
38 Correct 57 ms 4856 KB Output is correct
39 Correct 54 ms 4856 KB Output is correct
40 Correct 56 ms 4984 KB Output is correct
41 Correct 50 ms 2688 KB Output is correct
42 Correct 39 ms 2808 KB Output is correct
43 Correct 29 ms 2296 KB Output is correct
44 Correct 26 ms 1920 KB Output is correct
45 Correct 43 ms 2816 KB Output is correct
46 Correct 60 ms 2684 KB Output is correct
47 Correct 43 ms 2816 KB Output is correct
48 Correct 36 ms 2680 KB Output is correct
49 Correct 29 ms 2304 KB Output is correct
50 Correct 44 ms 2808 KB Output is correct
51 Correct 95 ms 5752 KB Output is correct
52 Correct 97 ms 5624 KB Output is correct
53 Correct 95 ms 5752 KB Output is correct
54 Correct 95 ms 5624 KB Output is correct
55 Correct 101 ms 5752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 63 ms 2168 KB Output is correct
27 Correct 69 ms 3064 KB Output is correct
28 Correct 62 ms 2808 KB Output is correct
29 Correct 59 ms 2680 KB Output is correct
30 Correct 62 ms 2680 KB Output is correct
31 Correct 52 ms 3448 KB Output is correct
32 Correct 56 ms 4728 KB Output is correct
33 Correct 56 ms 4780 KB Output is correct
34 Correct 54 ms 4728 KB Output is correct
35 Correct 51 ms 4600 KB Output is correct
36 Correct 53 ms 3448 KB Output is correct
37 Correct 53 ms 4728 KB Output is correct
38 Correct 57 ms 4856 KB Output is correct
39 Correct 54 ms 4856 KB Output is correct
40 Correct 56 ms 4984 KB Output is correct
41 Correct 50 ms 2688 KB Output is correct
42 Correct 39 ms 2808 KB Output is correct
43 Correct 29 ms 2296 KB Output is correct
44 Correct 26 ms 1920 KB Output is correct
45 Correct 43 ms 2816 KB Output is correct
46 Correct 60 ms 2684 KB Output is correct
47 Correct 43 ms 2816 KB Output is correct
48 Correct 36 ms 2680 KB Output is correct
49 Correct 29 ms 2304 KB Output is correct
50 Correct 44 ms 2808 KB Output is correct
51 Correct 95 ms 5752 KB Output is correct
52 Correct 97 ms 5624 KB Output is correct
53 Correct 95 ms 5752 KB Output is correct
54 Correct 95 ms 5624 KB Output is correct
55 Correct 101 ms 5752 KB Output is correct
56 Execution timed out 1088 ms 47224 KB Time limit exceeded
57 Halted 0 ms 0 KB -