답안 #708095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708095 2023-03-11T05:01:52 Z joelgun14 송금 (JOI19_remittance) C++17
0 / 100
1 ms 212 KB
// header file
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// pragma
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// macros
#define endl "\n"
#define ll long long
#define mp make_pair
#define ins insert
#define lb lower_bound
#define pb push_back
#define ub upper_bound
#define lll __int128
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    pair<ll, ll> a[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i].fi >> a[i].se;
    bool change = 1;
    for(int abc = 1; abc <= 100; ++abc) {
        change = 0;
        for(int j = 0; j < n; ++j) {
            if(a[j].fi > a[j].se) {
                ll diff = a[j].fi - a[j].se;
                //if(diff & 1)
                //    ++diff;
                if(diff & 1 && a[j].fi > a[j].se + 1)
                    ++diff;
                else
                    --diff;
                a[j].fi -= diff;
                a[(j + 1) % n].fi += diff / 2;
            }
        }
    }
    for(int i = 0; i < n; ++i) {
        if(a[i].fi != a[i].se)
            cout << "No" << endl, exit(0);
    }
    cout << "Yes" << endl;
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:30:10: warning: variable 'change' set but not used [-Wunused-but-set-variable]
   30 |     bool change = 1;
      |          ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -