Submission #1119854

# Submission time Handle Problem Language Result Execution time Memory
1119854 2024-11-27T14:01:46 Z Aviansh Pilot (NOI19_pilot) C++17
89 / 100
412 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,q;
    cin >> n >> q;
    int h[n];
    vector<int> mp[10000005];
    for(int i = 0;i<n;i++){
        cin >> h[i];
        mp[h[i]].push_back(i);
    }
    pair<int,int> qs[q];
    for(int i = 0;i<q;i++){
        int y;
        cin >> y;
        qs[i]={y,i};
    }
    sort(qs,qs+q);
    long long ans[q];
    long long currans = ((1LL*n*(n-1))/2)+n;
    set<pair<int,int>>rangs;
    rangs.insert({0,n-1});
    int las = 10000004;
    bool wor = 1;
    for(int i = q-1;i>=0;i--){
        while(wor&&las>qs[i].first){
            for(int i : (mp[las])){
                set<pair<int,int>>::iterator it = (--rangs.upper_bound({i,2e9}));
                pair<int,int>p = *it;
                int len = p.second-p.first+1;
                currans-=((1LL*len*(len-1))/2)+len;
                rangs.erase(it);
                if(p.first!=i){
                    rangs.insert({p.first,i-1});
                    len = i-p.first;
                    currans+=((1LL*len*(len-1))/2)+len;
                }
                if(p.second!=i){
                    rangs.insert({i+1,p.second});
                    len = p.second-i;
                    currans+=((1LL*len*(len-1))/2)+len;
                }
            }
            if(las==0){
                wor=0;
            }
            las--;

        }
        ans[qs[i].second]=currans;
    }
    for(long long i : ans){
        cout << i << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 261 ms 235080 KB Output is correct
12 Correct 258 ms 235080 KB Output is correct
13 Correct 277 ms 235100 KB Output is correct
14 Correct 245 ms 235268 KB Output is correct
15 Correct 259 ms 235084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 261 ms 235080 KB Output is correct
12 Correct 258 ms 235080 KB Output is correct
13 Correct 277 ms 235100 KB Output is correct
14 Correct 245 ms 235268 KB Output is correct
15 Correct 259 ms 235084 KB Output is correct
16 Correct 231 ms 235080 KB Output is correct
17 Correct 239 ms 235080 KB Output is correct
18 Correct 235 ms 235040 KB Output is correct
19 Correct 267 ms 235080 KB Output is correct
20 Correct 236 ms 235180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 261 ms 235080 KB Output is correct
12 Correct 258 ms 235080 KB Output is correct
13 Correct 277 ms 235100 KB Output is correct
14 Correct 245 ms 235268 KB Output is correct
15 Correct 259 ms 235084 KB Output is correct
16 Correct 231 ms 235080 KB Output is correct
17 Correct 239 ms 235080 KB Output is correct
18 Correct 235 ms 235040 KB Output is correct
19 Correct 267 ms 235080 KB Output is correct
20 Correct 236 ms 235180 KB Output is correct
21 Correct 261 ms 235308 KB Output is correct
22 Correct 271 ms 235092 KB Output is correct
23 Correct 263 ms 235336 KB Output is correct
24 Correct 229 ms 235188 KB Output is correct
25 Correct 252 ms 235080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 237384 KB Output is correct
2 Correct 279 ms 238408 KB Output is correct
3 Correct 240 ms 237384 KB Output is correct
4 Correct 270 ms 238152 KB Output is correct
5 Correct 271 ms 237384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 240820 KB Output is correct
2 Correct 264 ms 240968 KB Output is correct
3 Correct 271 ms 240968 KB Output is correct
4 Correct 257 ms 240968 KB Output is correct
5 Correct 266 ms 240712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 283 ms 241004 KB Output is correct
2 Correct 287 ms 240968 KB Output is correct
3 Correct 274 ms 240968 KB Output is correct
4 Correct 285 ms 241068 KB Output is correct
5 Correct 317 ms 241024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 238 ms 237384 KB Output is correct
12 Correct 279 ms 238408 KB Output is correct
13 Correct 240 ms 237384 KB Output is correct
14 Correct 270 ms 238152 KB Output is correct
15 Correct 271 ms 237384 KB Output is correct
16 Correct 276 ms 238132 KB Output is correct
17 Correct 306 ms 239620 KB Output is correct
18 Correct 298 ms 239688 KB Output is correct
19 Correct 313 ms 238408 KB Output is correct
20 Correct 315 ms 239480 KB Output is correct
21 Correct 278 ms 237444 KB Output is correct
22 Correct 296 ms 239240 KB Output is correct
23 Correct 281 ms 238772 KB Output is correct
24 Correct 324 ms 239376 KB Output is correct
25 Correct 302 ms 238532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 261 ms 235080 KB Output is correct
12 Correct 258 ms 235080 KB Output is correct
13 Correct 277 ms 235100 KB Output is correct
14 Correct 245 ms 235268 KB Output is correct
15 Correct 259 ms 235084 KB Output is correct
16 Correct 231 ms 235080 KB Output is correct
17 Correct 239 ms 235080 KB Output is correct
18 Correct 235 ms 235040 KB Output is correct
19 Correct 267 ms 235080 KB Output is correct
20 Correct 236 ms 235180 KB Output is correct
21 Correct 261 ms 235308 KB Output is correct
22 Correct 271 ms 235092 KB Output is correct
23 Correct 263 ms 235336 KB Output is correct
24 Correct 229 ms 235188 KB Output is correct
25 Correct 252 ms 235080 KB Output is correct
26 Correct 238 ms 237384 KB Output is correct
27 Correct 279 ms 238408 KB Output is correct
28 Correct 240 ms 237384 KB Output is correct
29 Correct 270 ms 238152 KB Output is correct
30 Correct 271 ms 237384 KB Output is correct
31 Correct 291 ms 240820 KB Output is correct
32 Correct 264 ms 240968 KB Output is correct
33 Correct 271 ms 240968 KB Output is correct
34 Correct 257 ms 240968 KB Output is correct
35 Correct 266 ms 240712 KB Output is correct
36 Correct 283 ms 241004 KB Output is correct
37 Correct 287 ms 240968 KB Output is correct
38 Correct 274 ms 240968 KB Output is correct
39 Correct 285 ms 241068 KB Output is correct
40 Correct 317 ms 241024 KB Output is correct
41 Correct 276 ms 238132 KB Output is correct
42 Correct 306 ms 239620 KB Output is correct
43 Correct 298 ms 239688 KB Output is correct
44 Correct 313 ms 238408 KB Output is correct
45 Correct 315 ms 239480 KB Output is correct
46 Correct 278 ms 237444 KB Output is correct
47 Correct 296 ms 239240 KB Output is correct
48 Correct 281 ms 238772 KB Output is correct
49 Correct 324 ms 239376 KB Output is correct
50 Correct 302 ms 238532 KB Output is correct
51 Correct 354 ms 241008 KB Output is correct
52 Correct 362 ms 241596 KB Output is correct
53 Correct 371 ms 240956 KB Output is correct
54 Correct 346 ms 241688 KB Output is correct
55 Correct 342 ms 240936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 235080 KB Output is correct
2 Correct 229 ms 235080 KB Output is correct
3 Correct 213 ms 235080 KB Output is correct
4 Correct 242 ms 235072 KB Output is correct
5 Correct 222 ms 235080 KB Output is correct
6 Correct 240 ms 235148 KB Output is correct
7 Correct 246 ms 235080 KB Output is correct
8 Correct 270 ms 235080 KB Output is correct
9 Correct 262 ms 235104 KB Output is correct
10 Correct 263 ms 235080 KB Output is correct
11 Correct 261 ms 235080 KB Output is correct
12 Correct 258 ms 235080 KB Output is correct
13 Correct 277 ms 235100 KB Output is correct
14 Correct 245 ms 235268 KB Output is correct
15 Correct 259 ms 235084 KB Output is correct
16 Correct 231 ms 235080 KB Output is correct
17 Correct 239 ms 235080 KB Output is correct
18 Correct 235 ms 235040 KB Output is correct
19 Correct 267 ms 235080 KB Output is correct
20 Correct 236 ms 235180 KB Output is correct
21 Correct 261 ms 235308 KB Output is correct
22 Correct 271 ms 235092 KB Output is correct
23 Correct 263 ms 235336 KB Output is correct
24 Correct 229 ms 235188 KB Output is correct
25 Correct 252 ms 235080 KB Output is correct
26 Correct 238 ms 237384 KB Output is correct
27 Correct 279 ms 238408 KB Output is correct
28 Correct 240 ms 237384 KB Output is correct
29 Correct 270 ms 238152 KB Output is correct
30 Correct 271 ms 237384 KB Output is correct
31 Correct 291 ms 240820 KB Output is correct
32 Correct 264 ms 240968 KB Output is correct
33 Correct 271 ms 240968 KB Output is correct
34 Correct 257 ms 240968 KB Output is correct
35 Correct 266 ms 240712 KB Output is correct
36 Correct 283 ms 241004 KB Output is correct
37 Correct 287 ms 240968 KB Output is correct
38 Correct 274 ms 240968 KB Output is correct
39 Correct 285 ms 241068 KB Output is correct
40 Correct 317 ms 241024 KB Output is correct
41 Correct 276 ms 238132 KB Output is correct
42 Correct 306 ms 239620 KB Output is correct
43 Correct 298 ms 239688 KB Output is correct
44 Correct 313 ms 238408 KB Output is correct
45 Correct 315 ms 239480 KB Output is correct
46 Correct 278 ms 237444 KB Output is correct
47 Correct 296 ms 239240 KB Output is correct
48 Correct 281 ms 238772 KB Output is correct
49 Correct 324 ms 239376 KB Output is correct
50 Correct 302 ms 238532 KB Output is correct
51 Correct 354 ms 241008 KB Output is correct
52 Correct 362 ms 241596 KB Output is correct
53 Correct 371 ms 240956 KB Output is correct
54 Correct 346 ms 241688 KB Output is correct
55 Correct 342 ms 240936 KB Output is correct
56 Runtime error 412 ms 262144 KB Execution killed with signal 9
57 Halted 0 ms 0 KB -