Submission #778935

# Submission time Handle Problem Language Result Execution time Memory
778935 2023-07-11T03:26:45 Z MinhAnhnd Remittance (JOI19_remittance) C++14
0 / 100
1 ms 212 KB
#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==7){
    bool checker = true;
    for (ll i = 1;i<=N;i++){
        if (A[i]!=B[i]+1) {
            checker = false;
        }
    }
    if (checker) {cout<<"Yes"; return 0;}
    }

    for (ll i = 1;i<=N;i++){
        if (A[i]!=B[i]) {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -