QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#883382 | #9549. The Magician | Nimi_Sora# | WA | 0ms | 3584kb | C++23 | 2.1kb | 2025-02-05 16:08:14 | 2025-02-05 16:08:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+7;
using pii=pair<int,int>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int tt=1;
cin>>tt;
while(tt--){
ll n;cin>>n;
vector<string>a(n+5);
vector<ll>cnt(10);
vector<ll>t(10);
for(int i=1;i<=n;i++){
cin>>a[i];char c=a[i][1];
if(c=='D')cnt[1]++;
else if(c='C')cnt[2]++;
else if(c='H')cnt[3]++;
else if(c='S')cnt[4]++;
}
for(int i=1;i<=6;i++)cin>>t[i];
ll ans=0;
ll sum=0,rest=0;
vector<pii>nn;
for(int i=1;i<=4;i++){
ans+=cnt[i]/5;
cnt[i]%=5;
sum+=cnt[i];
if(!t[i])rest+=cnt[i];
nn.emplace_back(t[i],cnt[i]);
}
ll up=sum/5;
ll ca=t[5]+t[6];
sort(all(nn),greater<pii>());
for(auto [it1,it2]:nn){
if(it1){
if(it2+3>=5){
ll need=5-it2;
if(rest>=need){
rest-=need;sum-=5;ans++;
}else if(sum-it2>=need){
sum-=5;rest=0;ans++;
}
}else if(it2+3+ca>=5){
ll need=5-it2;
ll nd;
if(it2==1)nd=1;else nd=2;
if(rest>=need){
rest-=need;sum-=5;ans++;ca-=nd;
}else if(sum-it2>=need){
sum-=5;rest=0;ans++;ca-=nd;
}
}
}else{
if(it2+ca>=5){
ll nd=5-it2;
if(rest>=nd){
rest-=nd;sum-=5;ans++;ca-=nd;
}else if(sum-it2>=nd){
sum-=5;rest=0;ans++;ca-=nd;
}
}
}
}
cout<<ans<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
4 5 2H 3H 4H 5H 6D 1 1 1 1 0 0 5 2S 3S 4D 5C 6D 0 0 1 0 1 1 5 2S 3S 4D 5C 6D 0 0 1 0 1 0 13 AS 2S 3S 4S 5H 6H 7H 8H 9H TH JH QH KH 0 0 0 0 0 1
output:
1 1 0 2
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
13 10 AD 2D 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2D 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3D 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3H 4D 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AH 2H 3H 4H 5D 6D 7D 8D 9D TD 0 0 1 0 0 0 10 AS 2S 3S 4S 5S 6S 7S 8S 9S TS 0 1 0 0 0 0 10 AC 2S 3S 4S 5S 6S 7S 8S ...
output:
2 1 1 1 1 2 2 2 2 2 0 0 0
result:
wrong answer 3rd lines differ - expected: '2', found: '1'