Submission #1987600


Source Code Expand

#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int N, M, K, s, a[59], b[59]; long long dp[1222222];
int main() {
	cin >> N >> M >> K;
	for (int i = 0; i < N; i++) cin >> a[i], s += a[i];
	for (int i = 0; i < M; i++) cin >> b[i], s += b[i];
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 1222210; j >= a[i]; j--) {
			dp[j] |= dp[j - a[i]] << 1;
		}
	}
	for (int i = 0; i <= 1222210; i++) {
		for (int j = 0; j <= N; j++) {
			if (j < N - K || j % 2 != (N - K % 2) % 2) {
				dp[i] |= ~(1LL << j);
			}
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 2444420; j >= b[i]; j--) {
			dp[j] |= dp[j - b[i]] << 1;
			if ((dp[j] >> (N + 1)) & 1) dp[j] -= 1LL << (N + 1);
		}
	}
	int best = -1, evl = 102345678;
	for (int i = 0; i <= s; i++) {
		int ev = i * 2 < s ? s - i * 2 : i * 2 - s;
		if (((dp[i] >> N) & 1) && ev < evl) {
			evl = ev;
			best = i;
		}
	}
	cout << 1LL * best * (s - best) << endl;
	return 0;
}

Submission Info

Submission Time
Task D - DDPC特別ビュッフェ
User square1001
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1003 Byte
Status RE
Exec Time 284 ms
Memory 9728 KB

Judge Result

Set Name Sample Subtask1 Subtask2 All
Score / Max Score 0 / 0 0 / 10 0 / 20 0 / 70
Status
RE × 2
RE × 17
RE × 45
RE × 101
Set Name Test Cases
Sample 000_example_01.txt, 000_example_02.txt
Subtask1 000_example_01.in, 010_rand_01.txt, 010_rand_02.txt, 010_rand_03.txt, 010_rand_04.txt, 010_rand_05.txt, 020_hand_01.txt, 020_hand_02.txt, 020_hand_03.txt, 020_hand_04.txt, 020_hand_05.txt, 020_hand_06.txt, 020_hand_07.txt, 030_max_01.txt, 030_max_02.txt, 030_max_03.txt, 030_max_04.txt, 030_max_05.txt
Subtask2 000_example_01.txt, 000_example_02.txt, 020_hand_01.txt, 020_hand_03.txt, 020_hand_07.txt, 050_rand_01.txt, 050_rand_02.txt, 050_rand_03.txt, 060_rand_01.txt, 060_rand_02.txt, 060_rand_03.txt, 060_rand_04.txt, 060_rand_05.txt, 060_rand_06.txt, 060_rand_07.txt, 060_rand_08.txt, 060_rand_09.txt, 060_rand_10.txt, 070_rand_01.txt, 070_rand_02.txt, 070_rand_03.txt, 070_rand_04.txt, 070_rand_05.txt, 070_rand_06.txt, 070_rand_07.txt, 070_rand_08.txt, 070_rand_09.txt, 070_rand_10.txt, 080_hand_01.txt, 080_hand_02.txt, 080_hand_03.txt, 080_hand_04.txt, 080_hand_05.txt, 080_hand_06.txt, 080_hand_07.txt, 080_hand_08.txt, 080_hand_09.txt, 080_hand_10.txt, 080_hand_11.txt, 090_anti_greedy_01.txt, 090_anti_greedy_02.txt, 090_anti_greedy_03.txt, 090_anti_greedy_04.txt, 090_anti_greedy_05.txt, 090_anti_greedy_06.txt
All 000_example_01.txt, 000_example_02.txt, 010_rand_01.txt, 010_rand_02.txt, 010_rand_03.txt, 010_rand_04.txt, 010_rand_05.txt, 020_hand_01.txt, 020_hand_02.txt, 020_hand_03.txt, 020_hand_04.txt, 020_hand_05.txt, 020_hand_06.txt, 020_hand_07.txt, 030_max_01.txt, 030_max_02.txt, 030_max_03.txt, 030_max_04.txt, 030_max_05.txt, 050_rand_01.txt, 050_rand_02.txt, 050_rand_03.txt, 060_rand_01.txt, 060_rand_02.txt, 060_rand_03.txt, 060_rand_04.txt, 060_rand_05.txt, 060_rand_06.txt, 060_rand_07.txt, 060_rand_08.txt, 060_rand_09.txt, 060_rand_10.txt, 070_rand_01.txt, 070_rand_02.txt, 070_rand_03.txt, 070_rand_04.txt, 070_rand_05.txt, 070_rand_06.txt, 070_rand_07.txt, 070_rand_08.txt, 070_rand_09.txt, 070_rand_10.txt, 080_hand_01.txt, 080_hand_02.txt, 080_hand_03.txt, 080_hand_04.txt, 080_hand_05.txt, 080_hand_06.txt, 080_hand_07.txt, 080_hand_08.txt, 080_hand_09.txt, 080_hand_10.txt, 080_hand_11.txt, 090_anti_greedy_01.txt, 090_anti_greedy_02.txt, 090_anti_greedy_03.txt, 090_anti_greedy_04.txt, 090_anti_greedy_05.txt, 090_anti_greedy_06.txt, 100_rand_01.txt, 100_rand_02.txt, 100_rand_03.txt, 100_rand_04.txt, 100_rand_05.txt, 100_rand_06.txt, 100_rand_07.txt, 100_rand_08.txt, 100_rand_09.txt, 100_rand_10.txt, 110_rand_01.txt, 110_rand_02.txt, 110_rand_03.txt, 110_rand_04.txt, 110_rand_05.txt, 110_rand_06.txt, 110_rand_07.txt, 110_rand_08.txt, 110_rand_09.txt, 110_rand_10.txt, 120_max_01.txt, 120_max_02.txt, 120_max_03.txt, 120_max_04.txt, 120_max_05.txt, 130_max_01.txt, 130_max_02.txt, 130_max_03.txt, 130_max_04.txt, 130_max_05.txt, 140_hand_01.txt, 140_hand_02.txt, 140_hand_03.txt, 140_hand_04.txt, 140_hand_05.txt, 140_hand_06.txt, 140_hand_07.txt, 140_hand_08.txt, 140_hand_09.txt, 140_hand_10.txt, 140_hand_11.txt, 140_hand_12.txt
Case Name Status Exec Time Memory
000_example_01.txt RE 252 ms 9728 KB
000_example_02.txt RE 110 ms 9728 KB
010_rand_01.txt RE 197 ms 9728 KB
010_rand_02.txt RE 194 ms 9728 KB
010_rand_03.txt RE 113 ms 9728 KB
010_rand_04.txt RE 124 ms 9728 KB
010_rand_05.txt RE 272 ms 9728 KB
020_hand_01.txt RE 106 ms 9728 KB
020_hand_02.txt RE 109 ms 9728 KB
020_hand_03.txt RE 273 ms 9728 KB
020_hand_04.txt RE 276 ms 9728 KB
020_hand_05.txt RE 124 ms 9728 KB
020_hand_06.txt RE 124 ms 9728 KB
020_hand_07.txt RE 116 ms 9728 KB
030_max_01.txt RE 276 ms 9728 KB
030_max_02.txt RE 276 ms 9728 KB
030_max_03.txt RE 276 ms 9728 KB
030_max_04.txt RE 275 ms 9728 KB
030_max_05.txt RE 276 ms 9728 KB
050_rand_01.txt RE 215 ms 9728 KB
050_rand_02.txt RE 194 ms 9728 KB
050_rand_03.txt RE 276 ms 9728 KB
060_rand_01.txt RE 215 ms 9728 KB
060_rand_02.txt RE 194 ms 9728 KB
060_rand_03.txt RE 275 ms 9728 KB
060_rand_04.txt RE 202 ms 9728 KB
060_rand_05.txt RE 156 ms 9728 KB
060_rand_06.txt RE 173 ms 9728 KB
060_rand_07.txt RE 148 ms 9728 KB
060_rand_08.txt RE 150 ms 9728 KB
060_rand_09.txt RE 121 ms 9728 KB
060_rand_10.txt RE 188 ms 9728 KB
070_rand_01.txt RE 193 ms 9728 KB
070_rand_02.txt RE 190 ms 9728 KB
070_rand_03.txt RE 114 ms 9728 KB
070_rand_04.txt RE 126 ms 9728 KB
070_rand_05.txt RE 251 ms 9728 KB
070_rand_06.txt RE 125 ms 9728 KB
070_rand_07.txt RE 190 ms 9728 KB
070_rand_08.txt RE 140 ms 9728 KB
070_rand_09.txt RE 143 ms 9728 KB
070_rand_10.txt RE 119 ms 9728 KB
080_hand_01.txt RE 109 ms 9728 KB
080_hand_02.txt RE 114 ms 9728 KB
080_hand_03.txt RE 117 ms 9728 KB
080_hand_04.txt RE 205 ms 9728 KB
080_hand_05.txt RE 117 ms 9728 KB
080_hand_06.txt RE 132 ms 9728 KB
080_hand_07.txt RE 253 ms 9728 KB
080_hand_08.txt RE 258 ms 9728 KB
080_hand_09.txt RE 121 ms 9728 KB
080_hand_10.txt RE 122 ms 9728 KB
080_hand_11.txt RE 121 ms 9728 KB
090_anti_greedy_01.txt RE 257 ms 9728 KB
090_anti_greedy_02.txt RE 256 ms 9728 KB
090_anti_greedy_03.txt RE 254 ms 9728 KB
090_anti_greedy_04.txt RE 255 ms 9728 KB
090_anti_greedy_05.txt RE 254 ms 9728 KB
090_anti_greedy_06.txt RE 254 ms 9728 KB
100_rand_01.txt RE 215 ms 9728 KB
100_rand_02.txt RE 196 ms 9728 KB
100_rand_03.txt RE 275 ms 9728 KB
100_rand_04.txt RE 204 ms 9728 KB
100_rand_05.txt RE 155 ms 9728 KB
100_rand_06.txt RE 173 ms 9728 KB
100_rand_07.txt RE 148 ms 9728 KB
100_rand_08.txt RE 151 ms 9728 KB
100_rand_09.txt RE 122 ms 9728 KB
100_rand_10.txt RE 185 ms 9728 KB
110_rand_01.txt RE 219 ms 9728 KB
110_rand_02.txt RE 189 ms 9728 KB
110_rand_03.txt RE 252 ms 9728 KB
110_rand_04.txt RE 206 ms 9728 KB
110_rand_05.txt RE 157 ms 9728 KB
110_rand_06.txt RE 165 ms 9728 KB
110_rand_07.txt RE 150 ms 9728 KB
110_rand_08.txt RE 153 ms 9728 KB
110_rand_09.txt RE 122 ms 9728 KB
110_rand_10.txt RE 188 ms 9728 KB
120_max_01.txt RE 256 ms 9728 KB
120_max_02.txt RE 258 ms 9728 KB
120_max_03.txt RE 255 ms 9728 KB
120_max_04.txt RE 284 ms 9728 KB
120_max_05.txt RE 282 ms 9728 KB
130_max_01.txt RE 256 ms 9728 KB
130_max_02.txt RE 257 ms 9728 KB
130_max_03.txt RE 255 ms 9728 KB
130_max_04.txt RE 256 ms 9728 KB
130_max_05.txt RE 254 ms 9728 KB
140_hand_01.txt RE 254 ms 9728 KB
140_hand_02.txt RE 145 ms 9728 KB
140_hand_03.txt RE 258 ms 9728 KB
140_hand_04.txt RE 255 ms 9728 KB
140_hand_05.txt RE 110 ms 9728 KB
140_hand_06.txt RE 114 ms 9728 KB
140_hand_07.txt RE 253 ms 9728 KB
140_hand_08.txt RE 116 ms 9728 KB
140_hand_09.txt RE 133 ms 9728 KB
140_hand_10.txt RE 255 ms 9728 KB
140_hand_11.txt RE 200 ms 9728 KB
140_hand_12.txt RE 252 ms 9728 KB