답안 #854972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854972 2023-09-29T14:23:02 Z vjudge1 송금 (JOI19_remittance) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;

int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	bool go = 1;
	while (go){
		go = 0;
		for (int i=0;i<n;i++){
			if (a[i] > b[i]){
				int d = (a[i]-b[i]);
				d = d/2 + d%2;
				a[i] -= 2*d;
				a[(i+1)%n] += d;
				go=1;
			}
		}
		for (int i=0;i<n;i++){
			if (a[i] < 0) break;
		}
	}
	bool flag = 1;
	for (int i=0;i<n;i++){
		flag &= (a[i]==b[i]);
	}
	cout << (flag ? "YES" : "NO") << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -