답안 #399790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
399790 2021-05-06T15:39:48 Z Fidisk Pilot (NOI19_pilot) C++14
89 / 100
65 ms 11952 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e15
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;

const ll base=361;
const ll mod=1e9+7;
const ld eps=1e-5;
const ll maxn=1e6;

ll n,m,i,a[500009],k,b[500009],r[500009],l[500009],j,ans,pre[500009];
vector<pll> g;
vector<ll> q;

int main(){
    IO;
    cin>>n>>m;
    for (i=1;i<=n;i++) {
        cin>>a[i];
    }
    for (i=1;i<=n;i++) {
        while (!q.empty()&&a[q.back()]<=a[i]) {
            r[q.back()]=i-1;
            q.pop_back();
        }
        q.push_back(i);
    }
    while (!q.empty()) {
        r[q.back()]=n;
        q.pop_back();
    }
    for (i=1;i<=n;i++) {
        while (!q.empty()&&a[q.back()]<=a[i]) {
            r[q.back()]=i-1;
            q.pop_back();
        }
        q.push_back(i);
    }
    while (!q.empty()) {
        r[q.back()]=n;
        q.pop_back();
    }
    for (i=n;i>=1;i--) {
        while (!q.empty()&&a[q.back()]<a[i]) {
            l[q.back()]=i+1;
            q.pop_back();
        }
        q.push_back(i);
    }
    while (!q.empty()) {
        l[q.back()]=1;
        q.pop_back();
    }
    for (i=1;i<=n;i++) {
        g.push_back({a[i],(i-l[i]+1)*(r[i]-i+1)});
    }
    sort(g.begin(),g.end());
    for (i=1;i<=n;i++) {
        b[i]=g[i-1].fi;
        pre[i]=pre[i-1]+g[i-1].se;
    }
    for (i=1;i<=m;i++) {
        cin>>k;
        ans=0;
        for (j=n;j>0;j/=2) {
            while (ans+j<=n&&k>=b[ans+j]) {
                ans+=j;
            }
        }
        cout<<pre[ans]<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 6332 KB Output is correct
2 Correct 28 ms 6504 KB Output is correct
3 Correct 25 ms 6076 KB Output is correct
4 Correct 25 ms 6032 KB Output is correct
5 Correct 26 ms 6036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 8380 KB Output is correct
2 Correct 48 ms 8412 KB Output is correct
3 Correct 47 ms 8312 KB Output is correct
4 Correct 47 ms 8640 KB Output is correct
5 Correct 47 ms 8252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 8616 KB Output is correct
2 Correct 55 ms 8504 KB Output is correct
3 Correct 54 ms 8400 KB Output is correct
4 Correct 53 ms 8964 KB Output is correct
5 Correct 56 ms 8640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 26 ms 6332 KB Output is correct
12 Correct 28 ms 6504 KB Output is correct
13 Correct 25 ms 6076 KB Output is correct
14 Correct 25 ms 6032 KB Output is correct
15 Correct 26 ms 6036 KB Output is correct
16 Correct 25 ms 6084 KB Output is correct
17 Correct 26 ms 6460 KB Output is correct
18 Correct 28 ms 6588 KB Output is correct
19 Correct 25 ms 5948 KB Output is correct
20 Correct 26 ms 6388 KB Output is correct
21 Correct 25 ms 5924 KB Output is correct
22 Correct 25 ms 6104 KB Output is correct
23 Correct 27 ms 6500 KB Output is correct
24 Correct 25 ms 6092 KB Output is correct
25 Correct 27 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 26 ms 6332 KB Output is correct
27 Correct 28 ms 6504 KB Output is correct
28 Correct 25 ms 6076 KB Output is correct
29 Correct 25 ms 6032 KB Output is correct
30 Correct 26 ms 6036 KB Output is correct
31 Correct 46 ms 8380 KB Output is correct
32 Correct 48 ms 8412 KB Output is correct
33 Correct 47 ms 8312 KB Output is correct
34 Correct 47 ms 8640 KB Output is correct
35 Correct 47 ms 8252 KB Output is correct
36 Correct 53 ms 8616 KB Output is correct
37 Correct 55 ms 8504 KB Output is correct
38 Correct 54 ms 8400 KB Output is correct
39 Correct 53 ms 8964 KB Output is correct
40 Correct 56 ms 8640 KB Output is correct
41 Correct 25 ms 6084 KB Output is correct
42 Correct 26 ms 6460 KB Output is correct
43 Correct 28 ms 6588 KB Output is correct
44 Correct 25 ms 5948 KB Output is correct
45 Correct 26 ms 6388 KB Output is correct
46 Correct 25 ms 5924 KB Output is correct
47 Correct 25 ms 6104 KB Output is correct
48 Correct 27 ms 6500 KB Output is correct
49 Correct 25 ms 6092 KB Output is correct
50 Correct 27 ms 6232 KB Output is correct
51 Correct 58 ms 7616 KB Output is correct
52 Correct 65 ms 7544 KB Output is correct
53 Correct 57 ms 7784 KB Output is correct
54 Correct 62 ms 7480 KB Output is correct
55 Correct 57 ms 7796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 420 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 26 ms 6332 KB Output is correct
27 Correct 28 ms 6504 KB Output is correct
28 Correct 25 ms 6076 KB Output is correct
29 Correct 25 ms 6032 KB Output is correct
30 Correct 26 ms 6036 KB Output is correct
31 Correct 46 ms 8380 KB Output is correct
32 Correct 48 ms 8412 KB Output is correct
33 Correct 47 ms 8312 KB Output is correct
34 Correct 47 ms 8640 KB Output is correct
35 Correct 47 ms 8252 KB Output is correct
36 Correct 53 ms 8616 KB Output is correct
37 Correct 55 ms 8504 KB Output is correct
38 Correct 54 ms 8400 KB Output is correct
39 Correct 53 ms 8964 KB Output is correct
40 Correct 56 ms 8640 KB Output is correct
41 Correct 25 ms 6084 KB Output is correct
42 Correct 26 ms 6460 KB Output is correct
43 Correct 28 ms 6588 KB Output is correct
44 Correct 25 ms 5948 KB Output is correct
45 Correct 26 ms 6388 KB Output is correct
46 Correct 25 ms 5924 KB Output is correct
47 Correct 25 ms 6104 KB Output is correct
48 Correct 27 ms 6500 KB Output is correct
49 Correct 25 ms 6092 KB Output is correct
50 Correct 27 ms 6232 KB Output is correct
51 Correct 58 ms 7616 KB Output is correct
52 Correct 65 ms 7544 KB Output is correct
53 Correct 57 ms 7784 KB Output is correct
54 Correct 62 ms 7480 KB Output is correct
55 Correct 57 ms 7796 KB Output is correct
56 Runtime error 57 ms 11952 KB Execution killed with signal 11
57 Halted 0 ms 0 KB -