답안 #321251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321251 2020-11-11T17:48:40 Z robosapien Pilot (NOI19_pilot) C++17
55 / 100
1000 ms 1388 KB
/*
* author: robosapien
* created: 2020-11-11 21:55:39
*/
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pii pair<int,int>

const int N = 100100;
struct SegmentTree{
    ll seg[4*N];
    void build(int node, int l, int r, int a[]){
        if(l == r){
            seg[node] = a[l];
            return;
        }
        int m = (l + r) >> 1;
        build(2*node + 1, l, m, a);
        build(2*node + 2, m+1, r, a);
        seg[node] = max( seg[2*node + 1], seg[2*node + 2] );
    }
    void update(int node, int i, int val, int l, int r){
        if(l == r){
            seg[node] = val;
            return;
        }
        int m = (l + r) >> 1;
        if(i <= m)
            update(2*node + 1, i, val, l, m);
        else update(2*node + 2, i, val, m+1, r);
        seg[node] = max(seg[2*node + 1], seg[2*node + 2]);
    }
    int query(int node, int sl, int sr, int ql, int qr){
        if(sl > qr or sr < ql)
            return 0;
        if(sl >= ql and sr <= qr)
            return seg[node];
        int m = (sl + sr) >> 1;
        int l = query(2*node + 1, sl, m, ql, qr);
        int r = query(2*node + 2, m+1, sr, ql, qr);
        return max(l, r);
    }
};
 
void solve(){
    int n, q;
    cin >> n >> q;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    // s.build(0,0,n-1,a);
    while(q--) {
        int h;
        cin >> h;
        ll ans = 0, cur = 0;
        for(int i = 0; i < n; ++i) {
            if(a[i] <= h)
                cur++;
            else {
                ans += cur * (cur + 1) / 2;
                cur = 0;
            }
        }
        ans += cur * (cur + 1) / 2;
        cout << ans << '\n';
    }
}

int main()
{
    bs;
    int t = 1; 
    // cin >> t;
    while(t--){
       solve(); 
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 4 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 748 KB Output is correct
2 Correct 10 ms 1388 KB Output is correct
3 Correct 9 ms 1260 KB Output is correct
4 Correct 11 ms 1260 KB Output is correct
5 Correct 9 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 1148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 9 ms 748 KB Output is correct
12 Correct 10 ms 1388 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 11 ms 1260 KB Output is correct
15 Correct 9 ms 1260 KB Output is correct
16 Correct 9 ms 1260 KB Output is correct
17 Correct 10 ms 1388 KB Output is correct
18 Correct 13 ms 1388 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 13 ms 1388 KB Output is correct
21 Correct 9 ms 1260 KB Output is correct
22 Correct 10 ms 1260 KB Output is correct
23 Correct 10 ms 1260 KB Output is correct
24 Correct 9 ms 1260 KB Output is correct
25 Correct 10 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 4 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 9 ms 748 KB Output is correct
27 Correct 10 ms 1388 KB Output is correct
28 Correct 9 ms 1260 KB Output is correct
29 Correct 11 ms 1260 KB Output is correct
30 Correct 9 ms 1260 KB Output is correct
31 Execution timed out 1084 ms 1148 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 236 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 4 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 9 ms 748 KB Output is correct
27 Correct 10 ms 1388 KB Output is correct
28 Correct 9 ms 1260 KB Output is correct
29 Correct 11 ms 1260 KB Output is correct
30 Correct 9 ms 1260 KB Output is correct
31 Execution timed out 1084 ms 1148 KB Time limit exceeded
32 Halted 0 ms 0 KB -