제출 #321624

#제출 시각아이디문제언어결과실행 시간메모리
321624Lawliet송금 (JOI19_remittance)C++17
0 / 100
1 ms384 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;

const int MAXN = 1000010;
const lli INF = 1000000000000000000LL;

int n;

lli diff[MAXN];

void impossible()
{
	printf("No\n");
	exit(0);
}

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
	{
		int a, b;
		scanf("%d %d",&a,&b);

		diff[i] = a - b;
	}

	lli xCur = 0;
	lli xCross = 0;

	for(int i = 1 ; i < n ; i++)
	{
		lli xNext = diff[i] + xCur;

		if( xNext%2 == 1 )
		{
			if( i >= 62 ) impossible();

			xCur++; xNext++;
			xCross += (1LL << (i - 1));
		}

		if( xNext < 0 )
		{
			if( i >= 62 ) impossible();

			lli p = (1LL << (i - 1));

			if( -xNext > INF/p ) impossible();

			xNext = 0;
			xCross += -xNext*p;
		}

		xCur = xNext/2;

		if( xCross >= INF ) impossible();
	}

	lli s = diff[n] + xCur;

	if( s%2 == 0 && s/2 == xCross ) printf("Yes\n");
	else impossible();
}

컴파일 시 표준 에러 (stderr) 메시지

remittance.cpp: In function 'int main()':
remittance.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
remittance.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   scanf("%d %d",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...