답안 #232407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232407 2020-05-16T23:56:39 Z limabeans 송금 (JOI19_remittance) C++17
0 / 100
578 ms 9976 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 10;






vector<int> b;
map<vector<int>,bool> cache;

bool solve(vector<int> a) {

    int n = a.size();
    if (a == b) return true;

    if (cache.count(a)) return cache[a];
    
    for (int i=0; i<n; i++) {
	if (a[i]<=b[i]) continue;

	
	for (int x=0; x<=8; x+=2) {
	    for (int y=0; y<=8; y+=2) {
		if (x>0||y>0) {
		    if (a[i]>=x+y) {
			vector<int> _a = a;
			_a[i]-=x;
			_a[(i+1)%n]+=x/2;
			_a[i]-=y;
			_a[(i-1+n)%n]+=y/2;
			if (solve(_a)) {
			    return cache[a] = true;
			}
		    }
		}
	    }
	}
    }
    return cache[a] = false;
}

int n;
vector<int> _a;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n;
    _a.resize(n);
    b.resize(n);
    
    for (int i=0; i<n; i++) {
	cin>>_a[i]>>b[i];
    }

    if (solve(_a)) out("Yes");
    out("No");

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 578 ms 9976 KB Output is correct
22 Correct 8 ms 512 KB Output is correct
23 Correct 295 ms 6712 KB Output is correct
24 Correct 18 ms 896 KB Output is correct
25 Incorrect 16 ms 896 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 578 ms 9976 KB Output is correct
22 Correct 8 ms 512 KB Output is correct
23 Correct 295 ms 6712 KB Output is correct
24 Correct 18 ms 896 KB Output is correct
25 Incorrect 16 ms 896 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 578 ms 9976 KB Output is correct
22 Correct 8 ms 512 KB Output is correct
23 Correct 295 ms 6712 KB Output is correct
24 Correct 18 ms 896 KB Output is correct
25 Incorrect 16 ms 896 KB Output isn't correct
26 Halted 0 ms 0 KB -