Submission #779072

# Submission time Handle Problem Language Result Execution time Memory
779072 2023-07-11T07:23:35 Z MinhAnhnd Remittance (JOI19_remittance) C++14
100 / 100
210 ms 36480 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>1){
    bool checker = true;
    bool hasmorethanone = false;
    for (ll i = 1;i<=N;i++){
        if (A[i]!=B[i]+1) {
            checker = false;
        }
        if (A[i]>1) hasmorethanone = true;
    }
    if (checker&hasmorethanone) {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 1 ms 352 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 0 ms 212 KB Output is correct
11 Correct 1 ms 264 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 0 ms 212 KB Output is correct
11 Correct 1 ms 264 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 328 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 328 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 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 0 ms 212 KB Output is correct
11 Correct 1 ms 264 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 328 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 328 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 328 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Correct 162 ms 35284 KB Output is correct
64 Correct 94 ms 19824 KB Output is correct
65 Correct 210 ms 34784 KB Output is correct
66 Correct 88 ms 19792 KB Output is correct
67 Correct 96 ms 21216 KB Output is correct
68 Correct 103 ms 23544 KB Output is correct
69 Correct 162 ms 35264 KB Output is correct
70 Correct 88 ms 19812 KB Output is correct
71 Correct 125 ms 21188 KB Output is correct
72 Correct 104 ms 23604 KB Output is correct
73 Correct 160 ms 35256 KB Output is correct
74 Correct 90 ms 19792 KB Output is correct
75 Correct 98 ms 21168 KB Output is correct
76 Correct 113 ms 23516 KB Output is correct
77 Correct 165 ms 35336 KB Output is correct
78 Correct 121 ms 27580 KB Output is correct
79 Correct 119 ms 27484 KB Output is correct
80 Correct 130 ms 27600 KB Output is correct
81 Correct 131 ms 27596 KB Output is correct
82 Correct 77 ms 19836 KB Output is correct
83 Correct 76 ms 19788 KB Output is correct
84 Correct 75 ms 19788 KB Output is correct
85 Correct 169 ms 36480 KB Output is correct
86 Correct 162 ms 36356 KB Output is correct
87 Correct 125 ms 28580 KB Output is correct
88 Correct 132 ms 28664 KB Output is correct