QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372112 | #4810. Add One | Beater | WA | 1ms | 3576kb | C++20 | 618b | 2024-03-30 22:05:58 | 2024-03-30 22:05:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,t,res,ans;
signed main()
{
vector<int>a;
map<int,int>m;
for(int i=1;i<=60;i++) a.push_back((1ll<<i)-1);
cin>>n;
while(n--)
{
cin>>t;
res^=t;
int f=0;
for(int i=59;i>=0;i--)
{
if(a[i]>t&&m.count(a[i]-t))
{
m[a[i]]++;
m[a[i]-t]--;
if(m[a[i]-t]==0) m.erase(a[i]-t);
f=1;
break;
}
}
if(f==0) m[t]++;
//for(auto i:m) cout<<i.first<<" "<<i.second<<"\n";
}
//cout<<res<<"\n";
for(auto i:m)
{
ans=max(ans,res^(i.first+1)^i.first);
}
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3568kb
input:
4 1 2 1 2
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
5 1 2 3 4 5
output:
14
result:
ok 1 number(s): "14"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
6 1 2 4 7 15 31
output:
47
result:
ok 1 number(s): "47"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3512kb
input:
5 41 40 50 11 36
output:
31
result:
wrong answer 1st numbers differ - expected: '99', found: '31'