답안 #242833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242833 2020-06-29T11:03:53 Z gs18115 Pilot (NOI19_pilot) C++14
100 / 100
939 ms 88652 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
int pa[1000010];
int par(int x)
{
    if(pa[x]==0)
        return x;
    return pa[x]=par(pa[x]);
}
ll cans;
ll sz[1000010];
inline void uni(int x,int y)
{
    x=par(x);
    y=par(y);
    if(x==y)
        return;
    cans-=sz[x]*(sz[x]+1)/2;
    cans-=sz[y]*(sz[y]+1)/2;
    pa[y]=x;
    sz[x]+=sz[y];
    cans+=sz[x]*(sz[x]+1)/2;
    return;
}
ll ans[1000010];
bool able[1000010];
vector<int>lst[1000010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin>>n>>q;
    vector<int>v(n);
    for(int&t:v)
        cin>>t;
    v.insert(v.begin(),inf);
    for(int i=0;i++<n;)
        lst[v[i]].eb(i);
    for(int i=0;i++<1000000;)
    {
        for(int&t:lst[i])
        {
            able[t]=1;
            cans+=sz[t]=1;
            if(able[t-1])
                uni(t-1,t);
            if(able[t+1])
                uni(t,t+1);
        }
        ans[i]=cans;
    }
    while(q-->0)
    {
        int x;
        cin>>x;
        cout<<ans[x]<<'\n';
    }
    cout.flush();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 30 ms 31616 KB Output is correct
12 Correct 30 ms 31744 KB Output is correct
13 Correct 27 ms 31744 KB Output is correct
14 Correct 26 ms 31616 KB Output is correct
15 Correct 26 ms 31616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 30 ms 31616 KB Output is correct
12 Correct 30 ms 31744 KB Output is correct
13 Correct 27 ms 31744 KB Output is correct
14 Correct 26 ms 31616 KB Output is correct
15 Correct 26 ms 31616 KB Output is correct
16 Correct 25 ms 31616 KB Output is correct
17 Correct 25 ms 31616 KB Output is correct
18 Correct 27 ms 31720 KB Output is correct
19 Correct 28 ms 31736 KB Output is correct
20 Correct 26 ms 31616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 30 ms 31616 KB Output is correct
12 Correct 30 ms 31744 KB Output is correct
13 Correct 27 ms 31744 KB Output is correct
14 Correct 26 ms 31616 KB Output is correct
15 Correct 26 ms 31616 KB Output is correct
16 Correct 25 ms 31616 KB Output is correct
17 Correct 25 ms 31616 KB Output is correct
18 Correct 27 ms 31720 KB Output is correct
19 Correct 28 ms 31736 KB Output is correct
20 Correct 26 ms 31616 KB Output is correct
21 Correct 26 ms 31736 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 25 ms 31744 KB Output is correct
24 Correct 27 ms 31744 KB Output is correct
25 Correct 27 ms 31744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 35836 KB Output is correct
2 Correct 76 ms 36856 KB Output is correct
3 Correct 65 ms 35768 KB Output is correct
4 Correct 89 ms 36504 KB Output is correct
5 Correct 55 ms 35596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 38280 KB Output is correct
2 Correct 70 ms 38280 KB Output is correct
3 Correct 72 ms 38164 KB Output is correct
4 Correct 87 ms 38396 KB Output is correct
5 Correct 66 ms 38164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 38500 KB Output is correct
2 Correct 84 ms 38332 KB Output is correct
3 Correct 79 ms 38348 KB Output is correct
4 Correct 74 ms 38768 KB Output is correct
5 Correct 78 ms 38532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 56 ms 35836 KB Output is correct
12 Correct 76 ms 36856 KB Output is correct
13 Correct 65 ms 35768 KB Output is correct
14 Correct 89 ms 36504 KB Output is correct
15 Correct 55 ms 35596 KB Output is correct
16 Correct 50 ms 35604 KB Output is correct
17 Correct 71 ms 36856 KB Output is correct
18 Correct 85 ms 36980 KB Output is correct
19 Correct 51 ms 35556 KB Output is correct
20 Correct 69 ms 36736 KB Output is correct
21 Correct 49 ms 35472 KB Output is correct
22 Correct 80 ms 36620 KB Output is correct
23 Correct 51 ms 35956 KB Output is correct
24 Correct 68 ms 36496 KB Output is correct
25 Correct 52 ms 35712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 30 ms 31616 KB Output is correct
12 Correct 30 ms 31744 KB Output is correct
13 Correct 27 ms 31744 KB Output is correct
14 Correct 26 ms 31616 KB Output is correct
15 Correct 26 ms 31616 KB Output is correct
16 Correct 25 ms 31616 KB Output is correct
17 Correct 25 ms 31616 KB Output is correct
18 Correct 27 ms 31720 KB Output is correct
19 Correct 28 ms 31736 KB Output is correct
20 Correct 26 ms 31616 KB Output is correct
21 Correct 26 ms 31736 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 25 ms 31744 KB Output is correct
24 Correct 27 ms 31744 KB Output is correct
25 Correct 27 ms 31744 KB Output is correct
26 Correct 56 ms 35836 KB Output is correct
27 Correct 76 ms 36856 KB Output is correct
28 Correct 65 ms 35768 KB Output is correct
29 Correct 89 ms 36504 KB Output is correct
30 Correct 55 ms 35596 KB Output is correct
31 Correct 71 ms 38280 KB Output is correct
32 Correct 70 ms 38280 KB Output is correct
33 Correct 72 ms 38164 KB Output is correct
34 Correct 87 ms 38396 KB Output is correct
35 Correct 66 ms 38164 KB Output is correct
36 Correct 78 ms 38500 KB Output is correct
37 Correct 84 ms 38332 KB Output is correct
38 Correct 79 ms 38348 KB Output is correct
39 Correct 74 ms 38768 KB Output is correct
40 Correct 78 ms 38532 KB Output is correct
41 Correct 50 ms 35604 KB Output is correct
42 Correct 71 ms 36856 KB Output is correct
43 Correct 85 ms 36980 KB Output is correct
44 Correct 51 ms 35556 KB Output is correct
45 Correct 69 ms 36736 KB Output is correct
46 Correct 49 ms 35472 KB Output is correct
47 Correct 80 ms 36620 KB Output is correct
48 Correct 51 ms 35956 KB Output is correct
49 Correct 68 ms 36496 KB Output is correct
50 Correct 52 ms 35712 KB Output is correct
51 Correct 76 ms 37248 KB Output is correct
52 Correct 105 ms 38024 KB Output is correct
53 Correct 77 ms 37188 KB Output is correct
54 Correct 100 ms 38020 KB Output is correct
55 Correct 76 ms 37236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 31616 KB Output is correct
2 Correct 29 ms 31616 KB Output is correct
3 Correct 28 ms 31616 KB Output is correct
4 Correct 24 ms 31616 KB Output is correct
5 Correct 28 ms 31616 KB Output is correct
6 Correct 27 ms 31740 KB Output is correct
7 Correct 25 ms 31744 KB Output is correct
8 Correct 32 ms 31616 KB Output is correct
9 Correct 25 ms 31744 KB Output is correct
10 Correct 25 ms 31608 KB Output is correct
11 Correct 30 ms 31616 KB Output is correct
12 Correct 30 ms 31744 KB Output is correct
13 Correct 27 ms 31744 KB Output is correct
14 Correct 26 ms 31616 KB Output is correct
15 Correct 26 ms 31616 KB Output is correct
16 Correct 25 ms 31616 KB Output is correct
17 Correct 25 ms 31616 KB Output is correct
18 Correct 27 ms 31720 KB Output is correct
19 Correct 28 ms 31736 KB Output is correct
20 Correct 26 ms 31616 KB Output is correct
21 Correct 26 ms 31736 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 25 ms 31744 KB Output is correct
24 Correct 27 ms 31744 KB Output is correct
25 Correct 27 ms 31744 KB Output is correct
26 Correct 56 ms 35836 KB Output is correct
27 Correct 76 ms 36856 KB Output is correct
28 Correct 65 ms 35768 KB Output is correct
29 Correct 89 ms 36504 KB Output is correct
30 Correct 55 ms 35596 KB Output is correct
31 Correct 71 ms 38280 KB Output is correct
32 Correct 70 ms 38280 KB Output is correct
33 Correct 72 ms 38164 KB Output is correct
34 Correct 87 ms 38396 KB Output is correct
35 Correct 66 ms 38164 KB Output is correct
36 Correct 78 ms 38500 KB Output is correct
37 Correct 84 ms 38332 KB Output is correct
38 Correct 79 ms 38348 KB Output is correct
39 Correct 74 ms 38768 KB Output is correct
40 Correct 78 ms 38532 KB Output is correct
41 Correct 50 ms 35604 KB Output is correct
42 Correct 71 ms 36856 KB Output is correct
43 Correct 85 ms 36980 KB Output is correct
44 Correct 51 ms 35556 KB Output is correct
45 Correct 69 ms 36736 KB Output is correct
46 Correct 49 ms 35472 KB Output is correct
47 Correct 80 ms 36620 KB Output is correct
48 Correct 51 ms 35956 KB Output is correct
49 Correct 68 ms 36496 KB Output is correct
50 Correct 52 ms 35712 KB Output is correct
51 Correct 76 ms 37248 KB Output is correct
52 Correct 105 ms 38024 KB Output is correct
53 Correct 77 ms 37188 KB Output is correct
54 Correct 100 ms 38020 KB Output is correct
55 Correct 76 ms 37236 KB Output is correct
56 Correct 817 ms 86436 KB Output is correct
57 Correct 854 ms 87908 KB Output is correct
58 Correct 830 ms 84132 KB Output is correct
59 Correct 939 ms 85816 KB Output is correct
60 Correct 878 ms 88652 KB Output is correct