답안 #683066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683066 2023-01-17T15:53:11 Z tht2005 송금 (JOI19_remittance) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

#define N 1000006
int a[N], b[N], tmp[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for(int t = 1; t < 1 << n; ++t) {
        bool ok = 1;
        for(int i = 0; i < n && ok; ++i) {
            if(!(t >> i & 1)) {
                continue;
            }
            vector<int> pos(1, i);
            for(int j = (i + 1) % n; !(t >> j & 1); j = (j + 1) % n) {
                pos.push_back(j);
            }
            for(int j : pos) {
                tmp[j] = a[j];
            }
            for(int j = 0; j < (int)pos.size(); ++j) {
                if(tmp[pos[j]] < b[pos[j]] || ((tmp[pos[j]] - b[pos[j]]) & 1)) {
                    ok = 0;
                    break;
                }
                if(b[pos[j]] != tmp[pos[j]] && j + 1 == (int)pos.size()) {
                    ok = 0;
                    break;
                }
                if(j + 1 < (int)pos.size()) {
                    tmp[pos[j + 1]] += (tmp[pos[j]] - b[pos[j]]) >> 1;
                }
            }
        }
        if(ok) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -