답안 #282232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282232 2020-08-24T07:43:52 Z aloo123 송금 (JOI19_remittance) C++14
0 / 100
610 ms 512 KB
        #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e6+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int a[N],b[N];
int n;
int nxt(int x){
    if(x == n) return 1;
    return x+1;
}
void solve(){
    cin >> n;   
    for(int i = 1;i <= n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 1;i <= n;i++){
        int ta[n+1],tb[n+1];
        for(int j = 1;j<=n;j++) ta[j]= a[j],tb[j] = b[j];
        int operations = 1;
        int cur = i;
        while(operations <= 1e7){
            bool ok = true;
            for(int j = 1;j<=n;j++)
                ok &= (ta[j] == tb[j]);
            if(ok){
                cout<<"Yes\n";
                return;
            }   
            int k = nxt(cur);
            if(ta[cur] > tb[cur]){
                int x = max((ta[cur]-tb[cur])/2,1ll);
                ta[cur] -= 2*x;
                ta[k] += (x);
            }
            cur = k;    
            operations++;
        }
    }
    cout<<"No\n";
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 583 ms 400 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 61 ms 384 KB Output is correct
13 Correct 198 ms 384 KB Output is correct
14 Correct 461 ms 384 KB Output is correct
15 Correct 610 ms 392 KB Output is correct
16 Correct 61 ms 384 KB Output is correct
17 Correct 199 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 610 ms 504 KB Output is correct
20 Incorrect 1 ms 384 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 583 ms 400 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 61 ms 384 KB Output is correct
13 Correct 198 ms 384 KB Output is correct
14 Correct 461 ms 384 KB Output is correct
15 Correct 610 ms 392 KB Output is correct
16 Correct 61 ms 384 KB Output is correct
17 Correct 199 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 610 ms 504 KB Output is correct
20 Incorrect 1 ms 384 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 583 ms 400 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 61 ms 384 KB Output is correct
13 Correct 198 ms 384 KB Output is correct
14 Correct 461 ms 384 KB Output is correct
15 Correct 610 ms 392 KB Output is correct
16 Correct 61 ms 384 KB Output is correct
17 Correct 199 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 610 ms 504 KB Output is correct
20 Incorrect 1 ms 384 KB Output isn't correct
21 Halted 0 ms 0 KB -