Submission #46330724


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll N = 100005;
ll n, cnt, s, c;
priority_queue <ll, vector <ll>, greater <ll> > q;
unordered_map <ll, ll> mp;

int main()
{
	scanf("%lld", &n);
	
	for (int i = 1; i <= n; i++)	
	{
		scanf("%lld%lld", &s, &c);
		q.push(s);
		mp[s] = c;
	}
	
	while (!q.empty())
	{
		ll num = q.top(), tot = mp[num];	q.pop();
		if (tot >= 2)
		{
			if (!mp[num * 2])	q.push(num * 2);
			mp[num * 2] += tot / 2;	
			if (tot % 2)	cnt++;
		}
		else	cnt++;
	}
	printf("%d", cnt);
}

Submission Info

Submission Time
Task D - Merge Slimes
User wangchai2009
Language C++ 20 (gcc 12.2)
Score 425
Code Size 569 Byte
Status AC
Exec Time 1474 ms
Memory 165540 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:33:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=]
   33 |         printf("%d", cnt);
      |                 ~^   ~~~
      |                  |   |
      |                  int ll {aka long long int}
      |                 %lld
Main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%lld", &n);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 scanf("%lld%lld", &s, &c);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 33
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3664 KiB
example_01.txt AC 1 ms 3676 KiB
example_02.txt AC 1 ms 3576 KiB
hand_00.txt AC 74 ms 14916 KiB
hand_01.txt AC 520 ms 83380 KiB
hand_02.txt AC 1231 ms 165468 KiB
hand_03.txt AC 1323 ms 165540 KiB
hand_04.txt AC 75 ms 14936 KiB
hand_05.txt AC 1 ms 3680 KiB
hand_06.txt AC 1 ms 3624 KiB
hand_07.txt AC 505 ms 83380 KiB
hand_08.txt AC 1 ms 3788 KiB
hand_09.txt AC 1 ms 3680 KiB
hand_10.txt AC 72 ms 14944 KiB
hand_11.txt AC 519 ms 83452 KiB
hand_12.txt AC 1002 ms 117716 KiB
hand_13.txt AC 1089 ms 117792 KiB
hand_14.txt AC 72 ms 14944 KiB
random_00.txt AC 146 ms 25540 KiB
random_01.txt AC 199 ms 30184 KiB
random_02.txt AC 250 ms 43144 KiB
random_03.txt AC 310 ms 43140 KiB
random_04.txt AC 291 ms 44596 KiB
random_05.txt AC 341 ms 46468 KiB
random_06.txt AC 196 ms 29060 KiB
random_07.txt AC 161 ms 27200 KiB
random_08.txt AC 1463 ms 117204 KiB
random_09.txt AC 1391 ms 117188 KiB
random_10.txt AC 1474 ms 117312 KiB
random_11.txt AC 1474 ms 117524 KiB
random_12.txt AC 1409 ms 117196 KiB
random_13.txt AC 1418 ms 117492 KiB
random_14.txt AC 1450 ms 117228 KiB