#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <limits>
#include <iomanip>
#include <cstring> //memset
using namespace std;
#define ll long long
#define ull unsigned ll
#define imi INT_MIN
#define ima (INT_MAX-10)
#define llmi LLONG_MIN+1
#define llma LLONG_MAX-1
#define dmi (double)llmi
#define dma (double)llma
#define forn(i,a,b) for(ll i = a; i < b; i++)
#define forn2(i,a,b) for(ll i = a; i >= b; i--)
#define fork(i,a,b,k) for(ll i = a; i <= b; i+=k)
#define fork2(i,a,b,k) for(ll i = a; i>=b; i-=k)
#define vl vector<ll>
#define sta stack<ll>
#define pq priority_queue<ll>
#define pb push_back
#define ppb pop_back
#define gt greater<int>()
#define w(t) while(t--)
#define setP(n) setprecision(n)
const int nmax = 1e5+5;
const int mod = 1e9+7;
const double eps = 1e-9;
bool checkPR(ll n) {
ll tmp = sqrt(n);
if(n == 2 || n == 3) return 1;
if(n <= 1 || n == 4) return 0;
if(n%2 == 0 || n%3 == 0) return 0;
fork(i,5,tmp,6) {
if(n%i == 0 || n%(i+2) == 0) return 0;
}
return 1;
}
bool checkSQ(ll n) {
ll tmp = trunc(sqrt(n));
return tmp*tmp == n;
}
int gcd(ll a, ll b) {
if(b == 0) return a;
return gcd(b, a%b);
}
int sumD(ll n) {
int ans = 0;
while(n) {
ans += n%10;
n /= 10;
}
return ans;
}
int cntD(ll n) {
int ans = 0;
while(n) {
ans++;
n/=10;
}
return ans;
}
bool pr[(int)1e6];
void eratos(ll n) {
forn(i,2,sqrt(n)) {
if(!pr[i]) fork(j, i*i, n, i) pr[j] = 1;
}
}
int cntDiv(ll n) {
int ans = 0;
forn(i,1,trunc(sqrt(n))+1) {
if(n%i == 0) ans += 2;
}
if(checkSQ(n)) ans--;
return ans;
}
ll fastMul(ll base, ll p) {
if(p == 1) return base;
ll tmp = fastMul(base, p/2) % mod;
ll res = (tmp*tmp) % mod;
if(p&1) res = (res*base) % mod;
return res;
}
double fastMul(double base, ll p) {
if(p == 1) return base;
double tmp = fastMul(base, p/2);
double res = tmp*tmp;
if(p&1) res *= base;
return res;
}
ll iMod(ll n) {
return fastMul(n, mod-2);
}
struct key {
ll v, pos;
} b[nmax];
struct itv {
ll b, e, pos;
};
bool ss1(key p, key q) {
return p.v < q.v;
}
pair<ll, ll> m[10];
bool ss(pair<ll, ll> p, pair<ll, ll> q) {
return p.second < q.second;
}
long long A[1000001];
long long B[1000001];
/*---------------------- ------------------------------------*/
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll N;
cin>>N;
for (ll i = 1;i<=N;i++){
cin>>A[i];
cin>>B[i];
}
bool mover = true;
while (mover){
mover = false;
for(ll i = 1;i<=N;i++){
if (A[i]>B[i]+1){
mover = true;
long transfer = (A[i]-B[i])/2;
if(i!=N) A[i+1] += transfer; else A[1] += transfer;
A[i] -= transfer*2;
}
}
}
if (N==2){
if ((A[1]-B[1] == 1) && (A[2]-B[2] == 1)){
cout<<"Yes";
return 0;
}
}
for (ll i = 1;i<=N;i++){
if (A[i]!=B[i]) {
cout<<"No";
return 0;
}
}
cout<<"Yes";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
324 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
324 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
324 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |