답안 #942109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942109 2024-03-10T09:17:48 Z dshfjka 송금 (JOI19_remittance) C++14
0 / 100
1 ms 432 KB
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
	LL n;
	scanf("%lld",&n);
	LL arr[n+5],tmp=-1;
	for(LL a=1;a<=n;a++)
	{
		LL x,y;
		scanf("%lld %lld",&x,&y);
		arr[a]=x-y;
		if(arr[a]<0)tmp=a;
	}
	if(tmp!=-1)
	{
		LL now=arr[tmp];
		arr[tmp]=0;
	//	printf("tmp=%lld\n",tmp);
		for(LL a=tmp-1;a>=1;a--)
		{
			now*=2;
			arr[a]+=now;
			if(arr[a]<0)
			{
				now=arr[a];
				arr[a]=0;
			}
			else{
				now=0;
			}
			if(now<=-1e9)
			{
				printf("No\n");
				exit(0);
			}
		//	printf("arr[%lld] = %lld dan %lld\n",a,arr[a],now);
		}
		for(LL b=1;b<=35;b++)
		{
			for(LL a=n;a>=1;a--)
			{
			//	printf("now=%lld\n",now);
				now*=2;
				arr[a]+=now;
				if(arr[a]<0)
				{
					now=arr[a];
					arr[a]=0;
				}
				else{
					now=0;
				}
			}
			if(now<=-1e9)
			{
				printf("No\n");
				exit(0);
			}
		}
	}
	
//	printf("SINI\n");
	for(LL b=1;b<=n;b++)
	{
		if(arr[b]>0 || arr[b]<0){
			printf("No\n");
			exit(0);
		}
	}
	printf("Yes\n");
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
remittance.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lld %lld",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -