QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#794892#9549. The MagicianneibWA 1ms3624kbC++201.4kb2024-11-30 16:42:042024-11-30 16:42:06

Judging History

This is the latest submission verdict.

  • [2024-11-30 16:42:06]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3624kb
  • [2024-11-30 16:42:04]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 200005;
ll t, n;
using pci = pair<char, int>;

int main()
{
	cin >> t;
	while(t--)
	{
		cin >> n;
		unordered_map <char, int> mp;
		for(int i = 1;i <= n;i++)
		{
			string s;
			cin >> s;
			mp[s[1]]++;
		}
		
		vector <pci> a(mp.begin(), mp.end());
		// sort(a.begin(), a.end(), [](const pci& x, const pci& y)
		// {
			// return x.first < y.first;
		// });
		ranges::sort(a);	
				
		int ans = 0;
		for(auto &[_, x] : a)
		{
			ans += x / 5;
			x %= 5;
		}
		
		
		vector <int> b(6);
		cin >> b[1] >> b[0] >> b[2] >> b[3] >> b[4] >> b[5];
		
		int plus = 0;
		for(int i = 0;i < (1 << 4);i++)
		{
			vector <int> temp;
			int sum = 0;
			for(int j = 0;j < 4;j++)
			{
				if(i >> j && 1)
				{
					temp.push_back(j);
				}
				else 
				{
					sum += a[j].second;
				}
			}
			
			auto temp_a = a;
			int u = b[4] + b[5];
			int plus_temp = 0;
			for(auto x : temp)
			{
				if(b[x])
				{
					int t = min({5 - temp_a[x].second, 3, sum});
					sum -= t;
					temp_a[x].second += t;
				}
				
				if(temp_a[x].second != 5)
				{
					while(u && sum && temp_a[x].second < 5)
					{
						temp_a[x].second++; u--; sum--;
					}
				}
				
				if(temp_a[x].second == 5)
				{
					plus_temp++;
				}
				plus = max(plus, plus_temp);
			}
		}
		cout << ans + plus << endl;
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3624kb

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:

0
0
0
2

result:

wrong answer 1st lines differ - expected: '1', found: '0'