Submission #35874262


Source Code Expand

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
using namespace std;
const int maxn = 1005;
const int N = 20000;
int n, x, y;
int n1, n2, a[maxn], b[maxn];
bool f[N * 2 + 123], g[N * 2 + 123], tmp[N * 2 + 123];
int main() {
#ifdef DEBUG
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> x >> y;
	for(int i = 1, t; i <= n; i++) {
		cin >> t;
		if(i == 1) {
			x -= t;
		}
		else if(i & 1) {
			a[++n1] = t;
		}
		else {
			b[++n2] = t;
		}
	}
	f[N] = g[N] = 1;
	for(int i = 1; i <= n1; i++) {
		memset(tmp, 0, sizeof(tmp));
		for(int j = -N; j <= N; j++) {
			if(f[j + N] && j + a[i] <= N) {
				tmp[j + a[i] + N] = 1;
			}
			if(f[j + N] && j - a[i] >= -N) {
				tmp[j - a[i] + N] = 1;
			}
		}
		memcpy(f, tmp, sizeof(f));
	}
	for(int i = 1; i <= n2; i++) {
		memset(tmp, 0, sizeof(tmp));
		for(int j = -N; j <= N; j++) {
			if(g[j + N] && j + b[i] <= N) {
				tmp[j + b[i] + N] = 1;
			}
			if(g[j + N] && j - b[i] >= -N) {
				tmp[j - b[i] + N] = 1;
			}
		}
		memcpy(g, tmp, sizeof(g));
	}
	if(f[x + N] && g[y + N]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Submission Info

Submission Time
Task D - Robot Arms 2
User yanchengzhi
Language C++ (GCC 9.2.1)
Score 400
Code Size 1290 Byte
Status AC
Exec Time 56 ms
Memory 3720 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 5
AC × 27
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 8 ms 3668 KiB
00_sample_01.txt AC 3 ms 3640 KiB
00_sample_02.txt AC 4 ms 3544 KiB
00_sample_03.txt AC 4 ms 3544 KiB
00_sample_04.txt AC 8 ms 3668 KiB
01_random_00.txt AC 44 ms 3716 KiB
01_random_01.txt AC 52 ms 3608 KiB
01_random_02.txt AC 14 ms 3616 KiB
01_random_03.txt AC 52 ms 3560 KiB
01_random_04.txt AC 46 ms 3612 KiB
01_random_05.txt AC 53 ms 3612 KiB
01_random_06.txt AC 36 ms 3696 KiB
01_random_07.txt AC 53 ms 3608 KiB
01_random_08.txt AC 17 ms 3672 KiB
01_random_09.txt AC 56 ms 3696 KiB
02_corner_00.txt AC 53 ms 3612 KiB
02_corner_01.txt AC 52 ms 3604 KiB
03_handmade_00.txt AC 53 ms 3612 KiB
03_handmade_01.txt AC 53 ms 3720 KiB
03_handmade_02.txt AC 50 ms 3608 KiB
03_handmade_03.txt AC 53 ms 3620 KiB
03_handmade_04.txt AC 51 ms 3544 KiB
03_handmade_05.txt AC 51 ms 3616 KiB
03_handmade_06.txt AC 53 ms 3612 KiB
03_handmade_07.txt AC 51 ms 3624 KiB
03_handmade_08.txt AC 4 ms 3620 KiB
03_handmade_09.txt AC 4 ms 3608 KiB