답안 #227339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227339 2020-04-27T04:44:23 Z Autoratch Pilot (NOI19_pilot) C++14
89 / 100
1000 ms 34552 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,l,r;

void add(int x)
{
    auto it = s.lower_bound({x,INT_MAX});
    int ll = x,rr = x;
    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+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 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 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 2304 KB Output is correct
2 Correct 65 ms 2296 KB Output is correct
3 Correct 60 ms 2168 KB Output is correct
4 Correct 57 ms 2168 KB Output is correct
5 Correct 64 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 3576 KB Output is correct
2 Correct 53 ms 3704 KB Output is correct
3 Correct 51 ms 3576 KB Output is correct
4 Correct 52 ms 3576 KB Output is correct
5 Correct 51 ms 3516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3448 KB Output is correct
2 Correct 51 ms 3576 KB Output is correct
3 Correct 53 ms 3528 KB Output is correct
4 Correct 53 ms 3448 KB Output is correct
5 Correct 56 ms 3708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 2304 KB Output is correct
12 Correct 65 ms 2296 KB Output is correct
13 Correct 60 ms 2168 KB Output is correct
14 Correct 57 ms 2168 KB Output is correct
15 Correct 64 ms 2296 KB Output is correct
16 Correct 49 ms 2168 KB Output is correct
17 Correct 37 ms 2168 KB Output is correct
18 Correct 28 ms 1656 KB Output is correct
19 Correct 26 ms 1408 KB Output is correct
20 Correct 43 ms 2168 KB Output is correct
21 Correct 58 ms 2176 KB Output is correct
22 Correct 42 ms 2168 KB Output is correct
23 Correct 35 ms 2040 KB Output is correct
24 Correct 27 ms 1664 KB Output is correct
25 Correct 43 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 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 2304 KB Output is correct
27 Correct 65 ms 2296 KB Output is correct
28 Correct 60 ms 2168 KB Output is correct
29 Correct 57 ms 2168 KB Output is correct
30 Correct 64 ms 2296 KB Output is correct
31 Correct 53 ms 3576 KB Output is correct
32 Correct 53 ms 3704 KB Output is correct
33 Correct 51 ms 3576 KB Output is correct
34 Correct 52 ms 3576 KB Output is correct
35 Correct 51 ms 3516 KB Output is correct
36 Correct 52 ms 3448 KB Output is correct
37 Correct 51 ms 3576 KB Output is correct
38 Correct 53 ms 3528 KB Output is correct
39 Correct 53 ms 3448 KB Output is correct
40 Correct 56 ms 3708 KB Output is correct
41 Correct 49 ms 2168 KB Output is correct
42 Correct 37 ms 2168 KB Output is correct
43 Correct 28 ms 1656 KB Output is correct
44 Correct 26 ms 1408 KB Output is correct
45 Correct 43 ms 2168 KB Output is correct
46 Correct 58 ms 2176 KB Output is correct
47 Correct 42 ms 2168 KB Output is correct
48 Correct 35 ms 2040 KB Output is correct
49 Correct 27 ms 1664 KB Output is correct
50 Correct 43 ms 2168 KB Output is correct
51 Correct 91 ms 4600 KB Output is correct
52 Correct 90 ms 4344 KB Output is correct
53 Correct 92 ms 4600 KB Output is correct
54 Correct 95 ms 4336 KB Output is correct
55 Correct 91 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 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 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 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 2304 KB Output is correct
27 Correct 65 ms 2296 KB Output is correct
28 Correct 60 ms 2168 KB Output is correct
29 Correct 57 ms 2168 KB Output is correct
30 Correct 64 ms 2296 KB Output is correct
31 Correct 53 ms 3576 KB Output is correct
32 Correct 53 ms 3704 KB Output is correct
33 Correct 51 ms 3576 KB Output is correct
34 Correct 52 ms 3576 KB Output is correct
35 Correct 51 ms 3516 KB Output is correct
36 Correct 52 ms 3448 KB Output is correct
37 Correct 51 ms 3576 KB Output is correct
38 Correct 53 ms 3528 KB Output is correct
39 Correct 53 ms 3448 KB Output is correct
40 Correct 56 ms 3708 KB Output is correct
41 Correct 49 ms 2168 KB Output is correct
42 Correct 37 ms 2168 KB Output is correct
43 Correct 28 ms 1656 KB Output is correct
44 Correct 26 ms 1408 KB Output is correct
45 Correct 43 ms 2168 KB Output is correct
46 Correct 58 ms 2176 KB Output is correct
47 Correct 42 ms 2168 KB Output is correct
48 Correct 35 ms 2040 KB Output is correct
49 Correct 27 ms 1664 KB Output is correct
50 Correct 43 ms 2168 KB Output is correct
51 Correct 91 ms 4600 KB Output is correct
52 Correct 90 ms 4344 KB Output is correct
53 Correct 92 ms 4600 KB Output is correct
54 Correct 95 ms 4336 KB Output is correct
55 Correct 91 ms 4600 KB Output is correct
56 Execution timed out 1093 ms 34552 KB Time limit exceeded
57 Halted 0 ms 0 KB -