답안 #162756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
162756 2019-11-09T15:59:04 Z Swan 송금 (JOI19_remittance) C++14
0 / 100
2 ms 380 KB
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("output.txt","w",stdout)
#define double long double
#define int long long
using namespace std;

typedef long long ll;

vector<pair<int,int> > v;

bool check(){
    for(int i(0); i < v.size();i++){
        if(v[i].first != v[i].second)return 0;
    }
    return 1;
}

bool solve(){
    for(int i(0); i < v.size();i++){
        int to = (i+1)%v.size();
        int can = v[i].first-v[i].second;
        if(can <= 0)continue;
        can/=2;
        if(can == 0)continue;
        can = 1;
        v[to].first+=can;
        v[i].first-=2*can;
        //cerr << i+1 << ' ' << can << endl;
        return 1;
    }
    return 0;
}

main()
{
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for(int i(0); i < n;i++){
        int a,b; cin >> a >> b;
        v.push_back({a,b});
    }
    //cerr << '\n';
    while(1){
        bool f = solve();
        if(!f)break;
    }
    if(!check())cout << "No";
    else cout << "Yes";
    return 0;
}
/*
3
1 3 3
4 6 3
7 9 3
*/

Compilation message

remittance.cpp: In function 'bool check()':
remittance.cpp:14:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < v.size();i++){
                   ~~^~~~~~~~~~
remittance.cpp: In function 'bool solve()':
remittance.cpp:21:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < v.size();i++){
                   ~~^~~~~~~~~~
remittance.cpp: At global scope:
remittance.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -