QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183124 | #5475. Make a Loop | real_sigma_team | WA | 1308ms | 330428kb | C++20 | 1.2kb | 2023-09-19 03:36:05 | 2023-09-19 03:36:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
const int N = 101;
const int R = 1e4 + 1;
int dp[N][N * R], r[N];
void solve() {
dp[0][0] = 1;
int n;
cin >> n;
if (n & 1) {
cout << "No\n";
return;
}
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> r[i];
sum += r[i];
}
if (sum & 1) {
cout << "No\n";
return;
}
int need = sum / 2;
sum = 0;
for (int i = 0; i < n; i++) {
int ri = r[i];
for (int j = i; j >= 0; j--) {
for (int l = 0; l <= sum; l++) {
dp[j + 1][l + ri] += dp[j][l];
dp[j + 1][l + ri] = min(dp[j + 1][l + ri], 2);
}
}
sum += ri;
}
bool ok = 0;
for (int i = 2; i < n; i += 2) {
if (dp[i][need] == 2) {
ok = true;
}
}
cout << (ok ? "Yes" : "No") << '\n';
}
int main() {
#ifndef LOCAL
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#else
freopen("input.txt", "r", stdin);
#endif
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 9584kb
input:
4 1 1 1 1
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 1ms
memory: 7552kb
input:
6 1 3 1 3 1 3
output:
Yes
result:
ok single line: 'Yes'
Test #3:
score: 0
Accepted
time: 0ms
memory: 7548kb
input:
6 2 2 1 1 1 1
output:
No
result:
ok single line: 'No'
Test #4:
score: 0
Accepted
time: 0ms
memory: 5528kb
input:
8 99 98 15 10 10 5 2 1
output:
Yes
result:
ok single line: 'Yes'
Test #5:
score: 0
Accepted
time: 1219ms
memory: 297548kb
input:
100 9384 9699 9434 9482 9525 39 26 9314 9610 9698 79 9558 9398 9358 9389 52 9395 286 9401 9449 9511 219 9291 9 9384 117 9344 98 9341 32 9375 8893 9414 9434 9412 9699 370 9363 9458 9639 9517 9347 9427 9357 9688 9456 9394 9455 9818 9436 9436 9228 9372 9345 9746 9540 9404 9475 9482 9535 9404 9400 28 91...
output:
No
result:
ok single line: 'No'
Test #6:
score: 0
Accepted
time: 1267ms
memory: 326020kb
input:
100 9398 9394 9457 9626 9490 104 9431 9403 9440 9360 9429 9483 9400 9371 9377 9275 9448 9491 9445 9408 9401 59 129 9396 9877 9241 9439 707 9454 9717 9484 9407 9472 9483 47 83 9535 9289 9509 243 9365 132 9352 9496 9571 9439 9365 9456 9924 9479 28 227 17 9358 9494 9311 9342 9300 9434 9731 9886 9654 94...
output:
Yes
result:
ok single line: 'Yes'
Test #7:
score: 0
Accepted
time: 1117ms
memory: 286228kb
input:
100 9624 9591 9595 9576 9924 131 9603 9597 9572 9585 9832 107 9611 9839 9055 9462 69 36 9415 9568 9575 9588 9605 21 28 5 9587 9645 594 9586 618 9563 9598 9545 9585 56 9577 9600 135 9627 9540 9599 9672 9989 9537 38 9546 9586 9585 9335 9546 9586 12 9574 9622 157 9927 9535 9200 9602 9585 9368 45 9265 6...
output:
No
result:
ok single line: 'No'
Test #8:
score: 0
Accepted
time: 1222ms
memory: 303788kb
input:
100 128 9316 9406 9544 9400 9450 9410 113 9454 8944 9427 9361 271 9427 9425 9415 9425 9312 9211 9539 9819 9445 97 9415 189 9443 9393 14 9570 9467 9429 9319 9458 9507 8746 9119 9425 9474 9268 9493 215 9648 57 199 9234 9045 88 9321 9424 176 9464 9362 9457 9434 9471 9463 9482 102 9408 9333 9611 9429 18...
output:
Yes
result:
ok single line: 'Yes'
Test #9:
score: 0
Accepted
time: 1308ms
memory: 330428kb
input:
100 9463 9505 9565 9478 9560 9859 9369 9540 9594 9628 299 9953 9608 9575 152 9542 109 9602 40 9459 9765 9511 9608 9483 9498 9486 9501 9566 9593 40 9567 9518 9550 9611 9570 9569 9538 9881 35 9595 9648 9607 208 9885 9525 9796 9158 9515 9527 9542 9561 9074 9653 9550 9390 9815 9529 9425 156 9460 9613 41...
output:
No
result:
ok single line: 'No'
Test #10:
score: 0
Accepted
time: 1225ms
memory: 305464kb
input:
100 9495 9516 9389 9446 9488 9480 9743 9405 9750 9671 9540 9526 6 9516 9560 223 9369 160 9217 9639 9803 9477 9325 342 30 9497 63 9516 9540 9389 9489 9494 9469 9297 9554 9180 144 9418 9448 9504 9379 9584 9581 9557 8580 9786 9339 82 9516 260 9491 9499 32 9516 9525 13 9521 13 9539 44 9659 9533 9465 946...
output:
Yes
result:
ok single line: 'Yes'
Test #11:
score: 0
Accepted
time: 1011ms
memory: 273316kb
input:
100 9519 31 9538 9419 9341 18 9479 248 9462 139 27 9375 9383 9440 78 9713 99 8996 9580 9326 183 9422 9432 9421 9055 9425 48 9403 9421 9485 9532 9404 9495 452 8928 9446 13 9426 9305 62 9466 65 198 9313 9355 9127 43 9416 30 202 9473 80 9385 9477 99 9738 9628 9443 9206 87 9432 9421 9372 9295 51 9386 93...
output:
No
result:
ok single line: 'No'
Test #12:
score: 0
Accepted
time: 1181ms
memory: 282228kb
input:
100 29 9664 11 9439 9514 9471 9477 9649 60 14 9441 9486 93 9579 9431 9479 12 9425 9431 9374 9129 21 68 9364 9166 9487 9298 9446 743 9435 9440 9743 9373 9368 9777 9551 9466 9220 9443 9443 9420 9430 9437 9440 9650 274 9439 9391 9284 9638 9442 9633 9459 9395 9748 9382 22 9329 58 9466 9591 9439 87 9470 ...
output:
Yes
result:
ok single line: 'Yes'
Test #13:
score: 0
Accepted
time: 1071ms
memory: 284700kb
input:
100 333 9362 37 9366 9546 9418 9414 9362 9490 18 402 328 9439 221 9445 9474 9400 21 9479 9648 9438 9455 9473 62 9535 9352 40 9570 9476 527 170 9688 9780 9453 9460 9702 6 9500 9496 9490 9595 9490 9429 9203 9491 9446 65 11 32 9179 9465 184 238 9460 9976 9490 9394 9436 9544 9441 9438 9454 9387 62 9472 ...
output:
No
result:
ok single line: 'No'
Test #14:
score: 0
Accepted
time: 1278ms
memory: 328088kb
input:
100 9305 9334 9338 9010 9479 131 9421 9319 9339 9311 9522 9138 9597 9415 9310 9013 9314 16 9032 9270 9436 9594 9316 71 9401 9180 9390 6 9405 178 29 9031 9275 9267 9229 9390 9301 9098 9173 9215 9292 9307 9357 9438 9304 330 9301 9316 9314 9347 9221 9290 44 18 9246 9399 9274 9468 9289 9338 9325 9386 93...
output:
Yes
result:
ok single line: 'Yes'
Test #15:
score: 0
Accepted
time: 44ms
memory: 31612kb
input:
86 949 929 899 943 934 917 922 903 936 909 912 953 810 959 894 912 929 889 908 904 944 896 899 903 907 923 907 949 851 900 975 922 906 920 930 907 905 916 917 877 849 920 937 887 937 895 900 849 894 927 883 876 906 996 954 939 845 882 883 898 930 929 922 919 898 925 946 928 910 912 907 895 872 945 9...
output:
No
result:
ok single line: 'No'
Test #16:
score: 0
Accepted
time: 77ms
memory: 39628kb
input:
98 930 898 910 918 920 927 901 928 913 943 915 953 916 933 915 893 946 889 939 922 946 958 911 933 921 898 918 907 912 920 965 893 897 947 863 928 928 928 915 895 906 916 929 909 880 947 915 953 914 914 921 871 919 861 881 882 934 920 915 962 893 902 889 912 896 893 891 855 982 877 899 919 910 954 8...
output:
Yes
result:
ok single line: 'Yes'
Test #17:
score: 0
Accepted
time: 10ms
memory: 20384kb
input:
68 909 896 897 917 880 886 869 911 896 33 913 893 920 897 899 903 896 891 878 20 912 924 901 891 912 17 28 915 882 901 902 896 906 908 894 900 934 912 918 906 897 893 906 948 907 905 919 19 932 932 906 898 913 2 869 910 933 887 899 873 904 903 908 904 43 955 916 910
output:
No
result:
ok single line: 'No'
Test #18:
score: 0
Accepted
time: 48ms
memory: 30432kb
input:
86 892 899 836 831 858 881 928 890 814 868 861 875 891 887 855 858 864 844 853 838 871 853 855 878 867 890 895 865 888 865 861 874 881 883 898 863 810 883 873 880 829 900 796 848 901 876 939 874 868 877 890 854 852 868 887 875 856 867 848 812 855 875 842 863 908 867 865 861 908 877 860 874 865 846 8...
output:
Yes
result:
ok single line: 'Yes'
Test #19:
score: -100
Wrong Answer
time: 0ms
memory: 7264kb
input:
28 538 894 915 386 833 911 889 486 208 156 529 820 412 421 451 963 989 946 451 464 807 178 451 100 499 716 356 295
output:
Yes
result:
wrong answer 1st lines differ - expected: 'No', found: 'Yes'