QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250409#7678. The GameMasterGwxWA 1ms3408kbC++142.1kb2023-11-13 09:21:432023-11-13 09:21:44

Judging History

你现在查看的是最新测评结果

  • [2023-11-13 09:21:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3408kb
  • [2023-11-13 09:21:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
typedef long long ll;
const int N=2e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const ll INF=1e18+3;
#define DEBUG 
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(x)
#else
#define debug(...) {}
#endif
//debug(n,m);debug("a,b");
//double max:0x7f,0x43 min:0xfe 0x c2  int:0x3f 
//运算符 priority  后缀 前缀 */+- 位移 比较 &^| && || 赋值
int T,t;
void solve()
{
    int n,m;
    int t;
    cin>>n>>m;
    vector<int> a(n),b(m),ans,res;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    t=a[n-m];
    // if(T==5292){
    //     if(t!=134) return;
    //     for(auto i:a) cout<<i<<' '; cout<<endl;
    //     for(auto i:b) cout<<i<<' '; cout<<endl;
    // }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int k=0,p1=n-1,p2=m-1;
    while(k<=n-m && p2>=0){
        if(a[p1]>b[p2] || k>p1) {
            cout<<-1<<'\n';
            return;
        }
        for(int i=a[p1];i<b[p2];i++) ans.push_back(i);
        k+=b[p2]-a[p1];
        a[p1]=b[p2];
        p2--,p1--;
    }
    //debug(k,p2);
    if(k>n-m || p2>=0){
        cout<<"-1\n";
        return;
    }
    //debug(p1,p2);
    priority_queue<int,vector<int>,greater<int>> q;
    //debug(k);
    p1=0;
    for(int i=0;i<n-m-k;i++) q.push(a[i]);
    //debug(q.size());
    for(int i=1;i<=n-m-k;i++){
        int x=q.top();
        q.pop();
        res.push_back(x);
        //debug(x);
        q.push(x+1);
        if(q.top()>t){
            cout<<"-1\n";
            return;
        }
        q.pop();
    }
    
    cout<<ans.size()+res.size()<<'\n';
    for(auto i:res) cout<<i<<" ";
    for(auto i:ans) cout<<i<<" ";
    cout<<'\n';
    return;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    #if 1 
         cin>>T; 
         for(int i=1;i<=T;i++) {
            t++;
            solve();

         }
    #else 
        solve();
    #endif 
    return 0; 
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3408kb

input:

6
5 3
1 2 2 3 3
2 3 4
4 2
1 2 2 4
2 4
5 2
2 3 3 4 4
5 5
6 1
1 1 1 1 1 1
4
4 2
1 1 1 2
2 2
4 1
1 1 1 1
2

output:

2
1 3 
-1
3
2 4 4 
-1
-1
-1

result:

wrong answer Jury has answer but participant has not (test case 4)