답안 #455196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
455196 2021-08-05T16:44:48 Z nguot Pilot (NOI19_pilot) C++14
89 / 100
1000 ms 243152 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define forinc(x,a,b) for (int x=a;x<=b;x++)
#define fordec(x,a,b) for (int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>i)&1)
#define batbit(x,i) (x|(1ll<<i))
#define tatbit(x,i) (x&~(1<<i))
#define gg exit(0);
 
const int N=1e6+10;
ll tab[N][21], f[N];
int a[N], n, q, lg2[N];
struct dat
{
    int l, r;
} val[N];
vector<int> h[N], cons[N];
void build()
{
    forinc(i,1,n) tab[i][0]=a[i];
    for(int j=1; j<=lg2[n] ; j++)
    {
        for(int i=1; i+(1<<j)-1<=n; i++) tab[i][j]=max(tab[i][j-1],tab[i+(1<<(j-1))][j-1]);
    }
}
ll query(int l, int r)
{
    int j=lg2[r-l+1];
    return max(tab[l][j],tab[r-(1<<j)+1][j]);
}
main()
{
    n=in; q=in;
    forinc(i,1,n) a[i]=in;
    forinc(i,1,n) h[a[i]].pb(i);
    forinc(i,2,n) lg2[i]=lg2[i/2]+1;
    build();
    forinc(i,1,n)
    {
        int l=0,r=i-1,l_bound=0,r_bound=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(query(i-mid,i)<=a[i])
            {
                l_bound=mid+1;
                l=mid+1;
            }
            else r=mid-1;
        }
        val[i].l=l_bound;
        l=0,r=n-i;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(query(i,i+mid)<=a[i])
            {
                r_bound=mid+1;
                l=mid+1;
            }
            else r=mid-1;
        }
        val[i].r=r_bound;
    }
    forinc(i,1,1e6)
    {
        f[i]=f[i-1];
        int last=-1;
        forv(pos,h[i])
        {
            if(last==-1) f[i]+=(ll)val[pos].l*val[pos].r;
            else f[i]+=(ll)min(pos-last,val[pos].l)*val[pos].r;
            last=pos;
        }
    }
    while(q--) cout << f[in] << "\n";
}

Compilation message

pilot.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 34 ms 55048 KB Output is correct
12 Correct 39 ms 55040 KB Output is correct
13 Correct 37 ms 55108 KB Output is correct
14 Correct 33 ms 55056 KB Output is correct
15 Correct 36 ms 55108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 34 ms 55048 KB Output is correct
12 Correct 39 ms 55040 KB Output is correct
13 Correct 37 ms 55108 KB Output is correct
14 Correct 33 ms 55056 KB Output is correct
15 Correct 36 ms 55108 KB Output is correct
16 Correct 38 ms 55156 KB Output is correct
17 Correct 40 ms 55064 KB Output is correct
18 Correct 42 ms 55156 KB Output is correct
19 Correct 39 ms 55088 KB Output is correct
20 Correct 35 ms 55108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 34 ms 55048 KB Output is correct
12 Correct 39 ms 55040 KB Output is correct
13 Correct 37 ms 55108 KB Output is correct
14 Correct 33 ms 55056 KB Output is correct
15 Correct 36 ms 55108 KB Output is correct
16 Correct 38 ms 55156 KB Output is correct
17 Correct 40 ms 55064 KB Output is correct
18 Correct 42 ms 55156 KB Output is correct
19 Correct 39 ms 55088 KB Output is correct
20 Correct 35 ms 55108 KB Output is correct
21 Correct 38 ms 55284 KB Output is correct
22 Correct 36 ms 55268 KB Output is correct
23 Correct 41 ms 55296 KB Output is correct
24 Correct 40 ms 55216 KB Output is correct
25 Correct 39 ms 55236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 74916 KB Output is correct
2 Correct 125 ms 76356 KB Output is correct
3 Correct 98 ms 74368 KB Output is correct
4 Correct 131 ms 74540 KB Output is correct
5 Correct 113 ms 74068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 76888 KB Output is correct
2 Correct 121 ms 76824 KB Output is correct
3 Correct 120 ms 76484 KB Output is correct
4 Correct 103 ms 77484 KB Output is correct
5 Correct 100 ms 76324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 77348 KB Output is correct
2 Correct 122 ms 76888 KB Output is correct
3 Correct 106 ms 76392 KB Output is correct
4 Correct 120 ms 78412 KB Output is correct
5 Correct 114 ms 77164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 121 ms 74916 KB Output is correct
12 Correct 125 ms 76356 KB Output is correct
13 Correct 98 ms 74368 KB Output is correct
14 Correct 131 ms 74540 KB Output is correct
15 Correct 113 ms 74068 KB Output is correct
16 Correct 98 ms 74108 KB Output is correct
17 Correct 113 ms 76276 KB Output is correct
18 Correct 116 ms 76508 KB Output is correct
19 Correct 111 ms 73812 KB Output is correct
20 Correct 109 ms 75900 KB Output is correct
21 Correct 95 ms 73892 KB Output is correct
22 Correct 115 ms 75172 KB Output is correct
23 Correct 105 ms 75500 KB Output is correct
24 Correct 111 ms 74784 KB Output is correct
25 Correct 97 ms 74784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 34 ms 55048 KB Output is correct
12 Correct 39 ms 55040 KB Output is correct
13 Correct 37 ms 55108 KB Output is correct
14 Correct 33 ms 55056 KB Output is correct
15 Correct 36 ms 55108 KB Output is correct
16 Correct 38 ms 55156 KB Output is correct
17 Correct 40 ms 55064 KB Output is correct
18 Correct 42 ms 55156 KB Output is correct
19 Correct 39 ms 55088 KB Output is correct
20 Correct 35 ms 55108 KB Output is correct
21 Correct 38 ms 55284 KB Output is correct
22 Correct 36 ms 55268 KB Output is correct
23 Correct 41 ms 55296 KB Output is correct
24 Correct 40 ms 55216 KB Output is correct
25 Correct 39 ms 55236 KB Output is correct
26 Correct 121 ms 74916 KB Output is correct
27 Correct 125 ms 76356 KB Output is correct
28 Correct 98 ms 74368 KB Output is correct
29 Correct 131 ms 74540 KB Output is correct
30 Correct 113 ms 74068 KB Output is correct
31 Correct 107 ms 76888 KB Output is correct
32 Correct 121 ms 76824 KB Output is correct
33 Correct 120 ms 76484 KB Output is correct
34 Correct 103 ms 77484 KB Output is correct
35 Correct 100 ms 76324 KB Output is correct
36 Correct 108 ms 77348 KB Output is correct
37 Correct 122 ms 76888 KB Output is correct
38 Correct 106 ms 76392 KB Output is correct
39 Correct 120 ms 78412 KB Output is correct
40 Correct 114 ms 77164 KB Output is correct
41 Correct 98 ms 74108 KB Output is correct
42 Correct 113 ms 76276 KB Output is correct
43 Correct 116 ms 76508 KB Output is correct
44 Correct 111 ms 73812 KB Output is correct
45 Correct 109 ms 75900 KB Output is correct
46 Correct 95 ms 73892 KB Output is correct
47 Correct 115 ms 75172 KB Output is correct
48 Correct 105 ms 75500 KB Output is correct
49 Correct 111 ms 74784 KB Output is correct
50 Correct 97 ms 74784 KB Output is correct
51 Correct 124 ms 76188 KB Output is correct
52 Correct 138 ms 76744 KB Output is correct
53 Correct 114 ms 76560 KB Output is correct
54 Correct 129 ms 76672 KB Output is correct
55 Correct 119 ms 76676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 55068 KB Output is correct
2 Correct 36 ms 55052 KB Output is correct
3 Correct 38 ms 55024 KB Output is correct
4 Correct 35 ms 55116 KB Output is correct
5 Correct 33 ms 55108 KB Output is correct
6 Correct 33 ms 55128 KB Output is correct
7 Correct 41 ms 55084 KB Output is correct
8 Correct 39 ms 55084 KB Output is correct
9 Correct 33 ms 55076 KB Output is correct
10 Correct 43 ms 55104 KB Output is correct
11 Correct 34 ms 55048 KB Output is correct
12 Correct 39 ms 55040 KB Output is correct
13 Correct 37 ms 55108 KB Output is correct
14 Correct 33 ms 55056 KB Output is correct
15 Correct 36 ms 55108 KB Output is correct
16 Correct 38 ms 55156 KB Output is correct
17 Correct 40 ms 55064 KB Output is correct
18 Correct 42 ms 55156 KB Output is correct
19 Correct 39 ms 55088 KB Output is correct
20 Correct 35 ms 55108 KB Output is correct
21 Correct 38 ms 55284 KB Output is correct
22 Correct 36 ms 55268 KB Output is correct
23 Correct 41 ms 55296 KB Output is correct
24 Correct 40 ms 55216 KB Output is correct
25 Correct 39 ms 55236 KB Output is correct
26 Correct 121 ms 74916 KB Output is correct
27 Correct 125 ms 76356 KB Output is correct
28 Correct 98 ms 74368 KB Output is correct
29 Correct 131 ms 74540 KB Output is correct
30 Correct 113 ms 74068 KB Output is correct
31 Correct 107 ms 76888 KB Output is correct
32 Correct 121 ms 76824 KB Output is correct
33 Correct 120 ms 76484 KB Output is correct
34 Correct 103 ms 77484 KB Output is correct
35 Correct 100 ms 76324 KB Output is correct
36 Correct 108 ms 77348 KB Output is correct
37 Correct 122 ms 76888 KB Output is correct
38 Correct 106 ms 76392 KB Output is correct
39 Correct 120 ms 78412 KB Output is correct
40 Correct 114 ms 77164 KB Output is correct
41 Correct 98 ms 74108 KB Output is correct
42 Correct 113 ms 76276 KB Output is correct
43 Correct 116 ms 76508 KB Output is correct
44 Correct 111 ms 73812 KB Output is correct
45 Correct 109 ms 75900 KB Output is correct
46 Correct 95 ms 73892 KB Output is correct
47 Correct 115 ms 75172 KB Output is correct
48 Correct 105 ms 75500 KB Output is correct
49 Correct 111 ms 74784 KB Output is correct
50 Correct 97 ms 74784 KB Output is correct
51 Correct 124 ms 76188 KB Output is correct
52 Correct 138 ms 76744 KB Output is correct
53 Correct 114 ms 76560 KB Output is correct
54 Correct 129 ms 76672 KB Output is correct
55 Correct 119 ms 76676 KB Output is correct
56 Execution timed out 1102 ms 243152 KB Time limit exceeded
57 Halted 0 ms 0 KB -