Submission #888107

# Submission time Handle Problem Language Result Execution time Memory
888107 2023-12-16T03:48:47 Z 8pete8 Remittance (JOI19_remittance) C++17
0 / 100
1 ms 600 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long/
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
const int mod=1e9+7,mxn=5e3+5,lg=30,inf=1e18,minf=-1e18;
int val[mxn+10],need[mxn+10];
int32_t main(){
    fastio
    int n;cin>>n;
    int mx=0;
    for(int i=0;i<n;i++){
        cin>>val[i]>>need[i];
        if(val[i]-need[i]>val[mx]-need[mx])mx=i;
    }
    for(int j=0;j<2;j++){
        for(int i=mx;i<mx+n;i++){
            int cur=i%n;
            if(val[cur]<need[cur]){
                cout<<"No";
                return 0;
            }
            val[(cur+1)%n]+=ceil((val[cur]-need[cur])*1.0/2);
            val[cur]-=ceil((val[cur]-need[cur])*1.0/2)*2;
            if(val[cur]<0){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -