Submission #57048666


Source Code Expand

Copy
#include <bits/stdc++.h>
#define int long long
using namespace std;
void print(priority_queue<int> q)
{
while (q.size())
{
printf("%lld ",q.top());
q.pop();
}
puts("");
}
signed main()
{
priority_queue<int> q;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
#define int long long
using namespace std;

void print(priority_queue<int> q)
{
	while (q.size())
	{
		printf("%lld ",q.top());
		q.pop();
	}
	puts("");
}

signed main()
{
	priority_queue<int> q;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		q.push(x);
	}
	int cnt = 0;
	while (q.size() > 1)
	{
		cnt++;
		int x = q.top();
		q.pop();
		int y = q.top();
		q.pop();
		if (x == 1 && y == 1) continue;
		if (y == 1) q.push(x - 1);
		else q.push(x - 1),q.push(y - 1);
//		print(q);
	}
	printf("%lld\n",cnt);
	return 0;
}

Submission Info

Submission Time
Task B - Decrease 2 max elements
User Hyh12377
Language C++ 20 (gcc 12.2)
Score 200
Code Size 609 Byte
Status AC
Exec Time 1 ms
Memory 3820 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 15
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_internal_00.txt, 01_internal_01.txt, 01_internal_02.txt, 01_internal_03.txt, 01_internal_04.txt, 01_internal_05.txt, 01_internal_06.txt, 01_internal_07.txt, 01_internal_08.txt, 01_internal_09.txt, 01_internal_10.txt, 01_internal_11.txt, 01_internal_12.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3812 KB
00_sample_01.txt AC 1 ms 3564 KB
01_internal_00.txt AC 1 ms 3752 KB
01_internal_01.txt AC 1 ms 3616 KB
01_internal_02.txt AC 1 ms 3820 KB
01_internal_03.txt AC 1 ms 3612 KB
01_internal_04.txt AC 1 ms 3580 KB
01_internal_05.txt AC 1 ms 3612 KB
01_internal_06.txt AC 1 ms 3696 KB
01_internal_07.txt AC 1 ms 3696 KB
01_internal_08.txt AC 1 ms 3624 KB
01_internal_09.txt AC 1 ms 3620 KB
01_internal_10.txt AC 1 ms 3752 KB
01_internal_11.txt AC 1 ms 3756 KB
01_internal_12.txt AC 1 ms 3556 KB


2025-04-03 (Thu)
21:00:22 +00:00