Submission #232404

# Submission time Handle Problem Language Result Execution time Memory
232404 2020-05-16T23:52:48 Z limabeans Remittance (JOI19_remittance) C++17
0 / 100
1000 ms 512 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;








bool solve(vector<int> a, vector<int> b) {

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

	
	for (int x=0; x<=20; x+=2) {
	    for (int y=0; y<=20; 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,b)) return true;
		    }
		}
	    }
	}
    }
    return false;
}

int n;
vector<int> _a, _b;

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,_b)) out("Yes");
    out("No");

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 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 4 ms 384 KB Output is correct
7 Correct 53 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 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 7 ms 384 KB Output is correct
20 Correct 21 ms 384 KB Output is correct
21 Execution timed out 1092 ms 384 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 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 4 ms 384 KB Output is correct
7 Correct 53 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 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 7 ms 384 KB Output is correct
20 Correct 21 ms 384 KB Output is correct
21 Execution timed out 1092 ms 384 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 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 4 ms 384 KB Output is correct
7 Correct 53 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 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 7 ms 384 KB Output is correct
20 Correct 21 ms 384 KB Output is correct
21 Execution timed out 1092 ms 384 KB Time limit exceeded
22 Halted 0 ms 0 KB -