Submission #239806

# Submission time Handle Problem Language Result Execution time Memory
239806 2020-06-17T10:23:36 Z mhy908 Pilot (NOI19_pilot) C++14
89 / 100
1000 ms 125304 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
#define lb(x, v) lower_bound(x.begin(), x.end(), v)
#define ub(x, v) upper_bound(x.begin(), x.end(), v)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2000000000000000000;
const LL mod1=1000000007;
const LL mod2=998244353;
const int inf=2000000000;
int n, q;
vector<int> vc[1000010];
LL ans[1000010];
struct SEGMENT_TREE{
    struct NODE{
        LL l, r, ans, len;
    }tree[4000010];
    NODE f(NODE a, NODE b){
        NODE ret={0, 0, 0, 0};
        ret.len=a.len+b.len;
        ret.ans=a.ans+b.ans+a.r*b.l;
        if(a.len==a.l)ret.l=a.l+b.l;
        else ret.l=a.l;
        if(b.len==b.r)ret.r=b.r+a.r;
        else ret.r=b.r;
        return ret;
    }
    void init(int point, int s, int e){
        if(s==e){
            tree[point]={0, 0, 0, 1};
            return;
        }
        init(point*2, s, (s+e)/2);
        init(point*2+1, (s+e)/2+1, e);
        tree[point]=f(tree[point*2], tree[point*2+1]);
    }
    void update(int point, int s, int e, int num){
        if(s==e){
            tree[point]={1, 1, 1, 1};
            return;
        }
        if(num<=(s+e)/2)update(point*2, s, (s+e)/2, num);
        else update(point*2+1, (s+e)/2+1, e, num);
        tree[point]=f(tree[point*2], tree[point*2+1]);
    }
    LL query(){return tree[1].ans;}
}seg;
int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        int a;
        scanf("%d", &a);
        vc[a].eb(i);
    }
    seg.init(1, 1, n);
    for(int i=1; i<=1000000; i++){
        for(auto j:vc[i])seg.update(1, 1, n, j);
        ans[i]=seg.query();
    }
    for(int i=1; i<=q; i++){
        int a;
        scanf("%d", &a);
        printf("%lld\n", ans[a]);
    }
}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
pilot.cpp:62:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
pilot.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 25 ms 31616 KB Output is correct
12 Correct 25 ms 31616 KB Output is correct
13 Correct 25 ms 31616 KB Output is correct
14 Correct 25 ms 31616 KB Output is correct
15 Correct 33 ms 31616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 25 ms 31616 KB Output is correct
12 Correct 25 ms 31616 KB Output is correct
13 Correct 25 ms 31616 KB Output is correct
14 Correct 25 ms 31616 KB Output is correct
15 Correct 33 ms 31616 KB Output is correct
16 Correct 28 ms 31616 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 26 ms 31616 KB Output is correct
19 Correct 26 ms 31872 KB Output is correct
20 Correct 25 ms 31616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 25 ms 31616 KB Output is correct
12 Correct 25 ms 31616 KB Output is correct
13 Correct 25 ms 31616 KB Output is correct
14 Correct 25 ms 31616 KB Output is correct
15 Correct 33 ms 31616 KB Output is correct
16 Correct 28 ms 31616 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 26 ms 31616 KB Output is correct
19 Correct 26 ms 31872 KB Output is correct
20 Correct 25 ms 31616 KB Output is correct
21 Correct 25 ms 31744 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 28 ms 31744 KB Output is correct
24 Correct 26 ms 31744 KB Output is correct
25 Correct 26 ms 31744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 42468 KB Output is correct
2 Correct 117 ms 43512 KB Output is correct
3 Correct 111 ms 42360 KB Output is correct
4 Correct 107 ms 43128 KB Output is correct
5 Correct 108 ms 42244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 44920 KB Output is correct
2 Correct 98 ms 44920 KB Output is correct
3 Correct 96 ms 44792 KB Output is correct
4 Correct 98 ms 45048 KB Output is correct
5 Correct 95 ms 44792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 45052 KB Output is correct
2 Correct 111 ms 44952 KB Output is correct
3 Correct 105 ms 44920 KB Output is correct
4 Correct 116 ms 45304 KB Output is correct
5 Correct 108 ms 45176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 101 ms 42468 KB Output is correct
12 Correct 117 ms 43512 KB Output is correct
13 Correct 111 ms 42360 KB Output is correct
14 Correct 107 ms 43128 KB Output is correct
15 Correct 108 ms 42244 KB Output is correct
16 Correct 96 ms 42232 KB Output is correct
17 Correct 114 ms 43384 KB Output is correct
18 Correct 139 ms 43512 KB Output is correct
19 Correct 98 ms 42208 KB Output is correct
20 Correct 114 ms 43512 KB Output is correct
21 Correct 100 ms 42232 KB Output is correct
22 Correct 114 ms 43256 KB Output is correct
23 Correct 114 ms 42488 KB Output is correct
24 Correct 109 ms 43236 KB Output is correct
25 Correct 103 ms 42360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 25 ms 31616 KB Output is correct
12 Correct 25 ms 31616 KB Output is correct
13 Correct 25 ms 31616 KB Output is correct
14 Correct 25 ms 31616 KB Output is correct
15 Correct 33 ms 31616 KB Output is correct
16 Correct 28 ms 31616 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 26 ms 31616 KB Output is correct
19 Correct 26 ms 31872 KB Output is correct
20 Correct 25 ms 31616 KB Output is correct
21 Correct 25 ms 31744 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 28 ms 31744 KB Output is correct
24 Correct 26 ms 31744 KB Output is correct
25 Correct 26 ms 31744 KB Output is correct
26 Correct 101 ms 42468 KB Output is correct
27 Correct 117 ms 43512 KB Output is correct
28 Correct 111 ms 42360 KB Output is correct
29 Correct 107 ms 43128 KB Output is correct
30 Correct 108 ms 42244 KB Output is correct
31 Correct 94 ms 44920 KB Output is correct
32 Correct 98 ms 44920 KB Output is correct
33 Correct 96 ms 44792 KB Output is correct
34 Correct 98 ms 45048 KB Output is correct
35 Correct 95 ms 44792 KB Output is correct
36 Correct 101 ms 45052 KB Output is correct
37 Correct 111 ms 44952 KB Output is correct
38 Correct 105 ms 44920 KB Output is correct
39 Correct 116 ms 45304 KB Output is correct
40 Correct 108 ms 45176 KB Output is correct
41 Correct 96 ms 42232 KB Output is correct
42 Correct 114 ms 43384 KB Output is correct
43 Correct 139 ms 43512 KB Output is correct
44 Correct 98 ms 42208 KB Output is correct
45 Correct 114 ms 43512 KB Output is correct
46 Correct 100 ms 42232 KB Output is correct
47 Correct 114 ms 43256 KB Output is correct
48 Correct 114 ms 42488 KB Output is correct
49 Correct 109 ms 43236 KB Output is correct
50 Correct 103 ms 42360 KB Output is correct
51 Correct 135 ms 43768 KB Output is correct
52 Correct 146 ms 44536 KB Output is correct
53 Correct 142 ms 43896 KB Output is correct
54 Correct 153 ms 44536 KB Output is correct
55 Correct 155 ms 43768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 31616 KB Output is correct
2 Correct 26 ms 31616 KB Output is correct
3 Correct 25 ms 31616 KB Output is correct
4 Correct 25 ms 31616 KB Output is correct
5 Correct 26 ms 31616 KB Output is correct
6 Correct 26 ms 31616 KB Output is correct
7 Correct 25 ms 31616 KB Output is correct
8 Correct 25 ms 31616 KB Output is correct
9 Correct 26 ms 31616 KB Output is correct
10 Correct 25 ms 31616 KB Output is correct
11 Correct 25 ms 31616 KB Output is correct
12 Correct 25 ms 31616 KB Output is correct
13 Correct 25 ms 31616 KB Output is correct
14 Correct 25 ms 31616 KB Output is correct
15 Correct 33 ms 31616 KB Output is correct
16 Correct 28 ms 31616 KB Output is correct
17 Correct 26 ms 31744 KB Output is correct
18 Correct 26 ms 31616 KB Output is correct
19 Correct 26 ms 31872 KB Output is correct
20 Correct 25 ms 31616 KB Output is correct
21 Correct 25 ms 31744 KB Output is correct
22 Correct 27 ms 31744 KB Output is correct
23 Correct 28 ms 31744 KB Output is correct
24 Correct 26 ms 31744 KB Output is correct
25 Correct 26 ms 31744 KB Output is correct
26 Correct 101 ms 42468 KB Output is correct
27 Correct 117 ms 43512 KB Output is correct
28 Correct 111 ms 42360 KB Output is correct
29 Correct 107 ms 43128 KB Output is correct
30 Correct 108 ms 42244 KB Output is correct
31 Correct 94 ms 44920 KB Output is correct
32 Correct 98 ms 44920 KB Output is correct
33 Correct 96 ms 44792 KB Output is correct
34 Correct 98 ms 45048 KB Output is correct
35 Correct 95 ms 44792 KB Output is correct
36 Correct 101 ms 45052 KB Output is correct
37 Correct 111 ms 44952 KB Output is correct
38 Correct 105 ms 44920 KB Output is correct
39 Correct 116 ms 45304 KB Output is correct
40 Correct 108 ms 45176 KB Output is correct
41 Correct 96 ms 42232 KB Output is correct
42 Correct 114 ms 43384 KB Output is correct
43 Correct 139 ms 43512 KB Output is correct
44 Correct 98 ms 42208 KB Output is correct
45 Correct 114 ms 43512 KB Output is correct
46 Correct 100 ms 42232 KB Output is correct
47 Correct 114 ms 43256 KB Output is correct
48 Correct 114 ms 42488 KB Output is correct
49 Correct 109 ms 43236 KB Output is correct
50 Correct 103 ms 42360 KB Output is correct
51 Correct 135 ms 43768 KB Output is correct
52 Correct 146 ms 44536 KB Output is correct
53 Correct 142 ms 43896 KB Output is correct
54 Correct 153 ms 44536 KB Output is correct
55 Correct 155 ms 43768 KB Output is correct
56 Execution timed out 1098 ms 125304 KB Time limit exceeded
57 Halted 0 ms 0 KB -