QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#256924 | #7627. Phony | ucup-team2580 | WA | 0ms | 3724kb | C++20 | 2.0kb | 2023-11-18 23:06:45 | 2023-11-18 23:06:46 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
void die(string S){puts(S.c_str());exit(0);}
array<ll,3> A[500500];
tree<pair<ll,int>,null_type,greater<pair<ll,int>>,rb_tree_tag,tree_order_statistics_node_update> tr;
tree<pair<ll,int>,null_type,greater<pair<ll,int>>,rb_tree_tag,tree_order_statistics_node_update> tr2;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
{
ll x;
cin>>x;
A[i]={x/k,x%k,i};
}
sort(A+1,A+n+1);
reverse(A+1,A+n+1);
int p=1;
ll sum=0;
tr.insert(mp(A[1][1],-A[1][2]));
for(int i=2;i<=n;i++)
tr2.insert(mp(A[i][0]*k+A[i][1],A[i][2]));
while(m--)
{
char ch;
cin>>ch;
if(ch=='C')
{
ll x;
cin>>x;
sum+=x;
}
while(p<n&&(A[p][0]-A[p+1][0])*p<=sum)
{
sum-=(A[p][0]-A[p+1][0])*p;
tr.insert(mp(A[p+1][1],-A[p+1][2]));
tr2.erase(mp(A[p+1][0]*k+A[p+1][1],A[p+1][2]));
p++;
}
if(ch=='A')
{
int x;
cin>>x;
int cnt=sum%p;
if(x>p)
{
cout<<tr2.find_by_order(x-p-1)->first<<'\n';
}
else if(x<=p-cnt)
{
ll val=tr.find_by_order(cnt+x-1)->first;
cout<<val+(A[p][0]-sum/p)*k<<'\n';
}
else
{
ll val=tr.find_by_order(x-p+cnt-1)->first;
cout<<val+(A[p][0]-sum/p-1)*k<<'\n';
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
3 5 5 7 3 9 A 3 C 1 A 2 C 2 A 3
output:
3 4 -1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
5 8 8 294 928 293 392 719 A 4 C 200 A 5 C 10 A 2 C 120 A 1 A 3
output:
294 200 191 0 -2
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3564kb
input:
100 100 233 5101 8001 6561 6329 6305 7745 4321 811 49 1121 3953 8054 8415 9876 6701 4097 6817 6081 495 5521 2389 2042 4721 8119 7441 7840 8001 5756 5561 129 1 5981 4801 7201 8465 7251 6945 5201 5626 3361 5741 3650 7901 2513 8637 3841 5621 9377 101 3661 5105 4241 5137 7501 5561 3581 4901 561 8721 811...
output:
6881 9161 4721 8200 2945 7647 7531 5291 5001 2042 4721 4721 6881 4097 7187 7218 7035 7018 811 6752 2561 6683 6103 6135 3581 5291 1485 5957 5393 2042 5303 5171 5205 4721 5084 4029 4097 4591 4816 4586 4705 2042 4535 4454 4603 4435 3581 4345 115 2042 4284 2042 4274 1485 4326 -17552
result:
wrong answer 23rd lines differ - expected: '6114', found: '6103'