ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#194366 | #2713. 8.2t2 | snow_trace | 100 | 1573ms | 13996kb | C++11 | 2.9kb | 2023-10-15 11:16:58 | 2023-10-15 12:31:36 |
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
priority_queue<pair<int,pair<int,int> > >q1,q2,del1,del2;
priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > > ,greater<pair<int,pair<int,int> > > >u1,del;
int a[200005],b[200005];
long long ans[1000005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 1;i<=n;i++){
cin >> a[i];
}for(int i = 1;i<=n;i++)cin >> b[i];
for(int i = 1;i<=n;i++){
q1.push({a[i],{i,1}});q2.push({a[i]+b[i],{i,1}});
}for(int i = 1;i<=3*n;i++){
//cout << " " << q2.top().first << " " << q2.top().second.first << " " << q2.top().second.second << endl;
//if(del.size())cout << " " << del2.top().first <<" " << del2.top().second.first << " " << del2.top().second.second << endl;
while(!del1.empty() and q1.top() == del1.top())q1.pop(),del1.pop();
while(!del2.empty() and q2.top() == del2.top())q2.pop(),del2.pop();
while(!del.empty() and u1.top() == del.top())u1.pop(),del.pop();
long long mx = ans[i-1]+q1.top().first,pos =1;
if(!q2.empty() and !u1.empty()){
if(ans[i-1]-u1.top().first+q2.top().first>mx)mx = max(ans[i-1]-u1.top().first+q2.top().first,mx),pos = 2;
}//cout << i << " " << pos << endl;
if(pos == 1){
int id = q1.top().second.first,s = q1.top().second.second;
// cout << " " << id << " " << s << endl;
u1.push(q1.top());q1.pop();
if(s == 3){
del.push({b[id],{id,2}});
}if(s == 2){
del2.push({a[id]+b[id],{id,2}});
// cout << a[id]+b[id] << " " << id << " " << 2 << endl;
del.push({a[id],{id,1}});
q1.push({a[id],{id,3}});
}if(s == 1){
del2.push({a[id]+b[id],{id,1}});q2.push({a[id]+b[id],{id,2}});
q1.push({b[id],{id,2}});
}
}else{
int id = q2.top().second.first,s = q2.top().second.second;
int id1 = u1.top().second.first,s1= u1.top().second.second;
// cout << " " << id << " " << s << " " << id1 << " " << s1 << endl;
q2.pop();u1.pop();
if(s == 1){
del1.push({a[id],{id,1}});q1.push({a[id],{id,3}});
u1.push({b[id],{id,2}});
}if(s == 2){
del1.push({b[id],{id,2}});u1.push({a[id],{id,3}});
}//q2.pop();
// cout << " " << del2.top().first <<" " << del2.top().second.first << " " << del2.top().second.second << endl;
// cout << " " << q2.top().first << " " << q2.top().second.first << " " << q2.top().second.second << endl;
if(s1 == 1){
q1.push({a[id1],{id1,1}});del1.push({b[id1],{id1,2}});
q2.push({a[id1]+b[id1],{id1,1}});del2.push({a[id1]+b[id1],{id1,2}});
}if(s1 == 2){
q1.push({b[id1],{id1,2}});del1.push({a[id1],{id1,3}});
q2.push({a[id1]+b[id1],{id1,2}});
}if(s1 == 3){
q1.push({a[id1],{id1,3}});
}
}ans[i] = mx;
}for(int i = 3*n+1;i<=m;i++)ans[i] = ans[3*n];
long long tot =0 ;
// for(int i = 1;i<=3*n;i++)cout << ans[i] << " ";cout << endl;
for(int i = 1;i<=m;i++)tot = tot^ans[i];
cout << tot << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1268kb
input:
4 10 2 2 4 8 8 4 7 10
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1272kb
input:
5 10 51072389 300657765 633439665 787090487 68456665 196385267 67864372 385977125 213928095 324494080
output:
3719844854
result:
ok 1 number(s): "3719844854"
Test #3:
score: 10
Accepted
time: 0ms
memory: 1268kb
input:
5 10 48720179 139181569 338164905 149648143 77222193 187724219 91625887 540142777 43334953 184586388
output:
215635088
result:
ok 1 number(s): "215635088"
Test #4:
score: 10
Accepted
time: 204ms
memory: 13648kb
input:
100000 102662 33421051 125633985 365251021 255717315 262377226 360896081 5951202 90071401 154444767 ...
output:
69628185742891
result:
ok 1 number(s): "69628185742891"
Test #5:
score: 10
Accepted
time: 215ms
memory: 13684kb
input:
100000 102838 588484254 69882126 151341881 500364775 68104321 134809939 50886121 98623841 274710921 ...
output:
2211168290969
result:
ok 1 number(s): "2211168290969"
Test #6:
score: 10
Accepted
time: 209ms
memory: 13660kb
input:
100000 102858 816229225 31491762 141788824 11587861 40202296 167103151 76959748 111706177 185028195 ...
output:
6040329651388
result:
ok 1 number(s): "6040329651388"
Test #7:
score: 10
Accepted
time: 235ms
memory: 13744kb
input:
100000 100 12830259 71768257 32489793 11032029 534815873 25056247 9333295 338811835 392555485 787185...
output:
4970387228
result:
ok 1 number(s): "4970387228"
Test #8:
score: 10
Accepted
time: 233ms
memory: 13660kb
input:
100000 100 72601214 53610670 93861411 367396001 45683503 4337367 98950041 888815737 409387861 106118...
output:
134182801545
result:
ok 1 number(s): "134182801545"
Test #9:
score: 10
Accepted
time: 231ms
memory: 13996kb
input:
100000 150000 667 605 113 157 314 281 1 234 801 121 561 414 25 953 434 233 421 601 993 969 209 695 7...
output:
33097015
result:
ok 1 number(s): "33097015"
Test #10:
score: 10
Accepted
time: 246ms
memory: 13240kb
input:
100000 150000 96 945 103 451 167 433 537 867 781 656 145 507 381 960 753 700 93 133 122 952 393 985 ...
output:
7610868
result:
ok 1 number(s): "7610868"