답안 #797125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797125 2023-07-29T07:02:56 Z fatemetmhr 송금 (JOI19_remittance) C++17
0 / 100
1 ms 340 KB
// Be name khoda // 

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second
#define mp     make_pair

typedef long long ll;

using namespace std;

const int maxn5 = 1e6 + 10;

bool mark[maxn5];
ll a[maxn5], b[maxn5];
queue <int> q;


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	int n; cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		if(a[i] - b[i] > 1){	
			mark[i] = true;
			q.push(i);
		}
	}

	while(q.size()){
		int i = q.front();
		q.pop();
		mark[i] = false;
		int j = (i + 1) % n;
		a[j] += (a[i] - b[i]) / 2;
		a[i] -= (a[i] - b[i]) / 2 * 2;
		assert(a[i] >= 0 && a[i] >= b[i]);
		if(a[j] - b[j] > 1 && !mark[j]){
			q.push(j);
			mark[j] = true;
		}
	}
	bool re = true;
	for(int i = 0; i < n; i++)
		re &= (a[i] == b[i]);
	cout << (re ? "Yes" : "No") << endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -