172412025-06-07 19:06:36gfaragoGamecpp17Wrong answer 0/1002.599s3816 KiB
#include <bits/stdc++.h>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);cin.tie(NULL);
    #define int long
	int n, k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int>q(n+1);
    while(k--){
        int x;cin>>x;
        priority_queue<int> qq;
        for(int i=0;i<x;i++){
            qq.push(a[i]);
            q[a[i]]++;
        }
        int alice=qq.top(), bob=0;
        qq.pop();
        for(int i=1;i<n;i++){
            if(i%2==0){
                if(i+x-1<n && a[i+x-1]>qq.top()){
                    alice+=a[i+x-1];
                }else{
                    if(i+x-1<n) q[a[i+x-1]]++;
                    alice+=qq.top();
                    qq.pop();
                }
            }else{
                if(i+x-1<n && a[i+x-1]>qq.top()){
                    bob+=a[i+x-1];
                }else{
                    if(i+x-1<n) q[a[i+x-1]]++;
                    bob+=qq.top();
                    qq.pop();
                }
            }
        }
        cout<<alice-bob<<'\n';
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/10
1Wrong answer1ms316 KiB
2Wrong answer1ms508 KiB
subtask20/20
1Wrong answer2ms316 KiB
2Wrong answer1ms316 KiB
3Wrong answer7ms444 KiB
4Wrong answer17ms448 KiB
subtask30/70
1Wrong answer168ms316 KiB
2Wrong answer178ms748 KiB
3Wrong answer555ms932 KiB
4Wrong answer671ms792 KiB
5Time limit exceeded2.588s2244 KiB
6Time limit exceeded2.599s2144 KiB
7Time limit exceeded2.581s2132 KiB
8Time limit exceeded2.584s3412 KiB
9Time limit exceeded2.588s3544 KiB
10Time limit exceeded2.599s3652 KiB
11Time limit exceeded2.584s3768 KiB
12Time limit exceeded2.578s3484 KiB
13Time limit exceeded2.591s3672 KiB
14Time limit exceeded2.599s3816 KiB