답안 #321624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321624 2020-11-12T23:34:10 Z Lawliet 송금 (JOI19_remittance) C++17
0 / 100
1 ms 384 KB
#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();
}

Compilation message

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);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -