QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544222 | #7678. The Game | ucup-team2179# | WA | 0ms | 3564kb | C++20 | 1.8kb | 2024-09-02 13:07:40 | 2024-09-02 13:07:40 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int, int>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 998244353;
void solve(){
int n, m;
cin >> n >> m;
multiset<int> a, b;
for (int i = 0; i < n;i++){
int u;
cin >> u;
a.insert(u);
}
for (int i = 0; i < m;i++){
int u;
cin >> u;
b.insert(u);
}
map<int, int> mp;
for(auto p:a){
if(b.count(p))
mp[p] = min(b.count(p), a.count(p));
}
for(auto [v,cnt]:mp){
for (int i = 0; i < cnt;i++){
a.erase(a.find(v));
b.erase(b.find(v));
}
}
int mi = *b.begin();
// cout << a.size() << " SS " << b.size() << "\n";
int flag = 1;
vector<int> ans;
for (int i = 0; i < n - m;i++){
if(b.empty()){
int u = *(a.begin());
if(u>=mi)
flag = 0;
ans.pb(u);
a.erase(a.find(u));
a.insert(u + 1);
a.erase(a.begin());
}
else {
int u = *(a.rbegin());
ans.pb(u);
a.erase(a.find(u));
if(b.count(u+1))
b.erase(b.find(u + 1));
else
a.insert(u + 1);
a.erase(a.begin());
}
}
// cout << a.size() << " " << b.size() << "\n";
if(b.size()||a.size()||flag==0){
cout << -1<<"\n";
}
else {
cout << ans.size() << "\n";
for(auto p:ans)
cout << p << " ";
cout << '\n';
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
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 3 2 -1 3 4 4 3 5 1 2 3 1 2 2 1 1 -1
result:
wrong answer Wrong answer, the final sequence does not equal to B (test case 1)