Submission #1587844
Source Code Expand
#include <iostream> #include <vector> #include <set> using namespace std; int main(){ int n, k; cin >> n >> k; int a[n]; for(int &i:a) cin >> i; if(n == 1){ cout << (k <= a[0]) << endl; return 0; } vector<set<int>> l(n); l[0].insert(0); if(a[0] < k) l[0].insert(a[0]); for(int i = 1; i < n; i++){ for(int x:l[i - 1]){ l[i].insert(x); if(x + a[i] < k) l[i].insert(x + a[i]); } } vector<set<int>> r(n); r[0].insert(0); if(a[n - 1] < k) r[0].insert(a[n - 1]); for(int i = n - 2; 0 <= i; i--){ for(int x:r[n - i - 2]){ r[n - i - 1].insert(x); if(x + a[i] < k) r[n - i - 1].insert(x + a[i]); } } int ans = 0; { auto itr = r[n - 2].lower_bound(k - a[0]); if(itr == r[n - 2].end()) ans++; auto itr2 = l[n - 2].lower_bound(k - a[n - 1]); if(itr2 == l[n - 2].end()) ans++; } for(int i = 1; i < n - 1; i++){ for(int x:l[i - 1]){ auto itr = r[i - 1].lower_bound(k - a[i] - x); if(itr != r[i - 1].end()) goto next; } ans++; next:; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - No Need |
User | jbyxm |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1060 Byte |
Status | WA |
Exec Time | 2171 ms |
Memory | 1069824 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 300 | ||||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
Subtask | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt, 2_037.txt, 2_038.txt, 2_039.txt, 2_040.txt, 2_041.txt, 2_042.txt, 2_043.txt, 2_044.txt, 2_045.txt, 2_046.txt, 2_047.txt, 2_048.txt, 2_049.txt, 2_050.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | WA | 1 ms | 256 KB |
1_004.txt | WA | 1 ms | 256 KB |
1_005.txt | WA | 1 ms | 256 KB |
1_006.txt | WA | 1 ms | 384 KB |
1_007.txt | WA | 1 ms | 384 KB |
1_008.txt | WA | 20 ms | 7808 KB |
1_009.txt | WA | 19 ms | 7808 KB |
1_010.txt | AC | 1 ms | 384 KB |
1_011.txt | AC | 1 ms | 384 KB |
1_012.txt | AC | 1 ms | 256 KB |
1_013.txt | AC | 1 ms | 384 KB |
1_014.txt | AC | 1 ms | 384 KB |
1_015.txt | WA | 42 ms | 14336 KB |
1_016.txt | WA | 1 ms | 256 KB |
1_017.txt | WA | 1 ms | 256 KB |
1_018.txt | WA | 1 ms | 256 KB |
1_019.txt | WA | 7 ms | 3072 KB |
1_020.txt | AC | 2 ms | 512 KB |
1_021.txt | AC | 18 ms | 6656 KB |
1_022.txt | AC | 8 ms | 2944 KB |
1_023.txt | WA | 3 ms | 768 KB |
1_024.txt | WA | 10 ms | 4224 KB |
1_025.txt | WA | 13 ms | 5760 KB |
2_026.txt | WA | 1 ms | 256 KB |
2_027.txt | WA | 2 ms | 640 KB |
2_028.txt | WA | 2 ms | 640 KB |
2_029.txt | TLE | 2161 ms | 935040 KB |
2_030.txt | TLE | 2160 ms | 936448 KB |
2_031.txt | AC | 4 ms | 1152 KB |
2_032.txt | AC | 4 ms | 1152 KB |
2_033.txt | AC | 3 ms | 1152 KB |
2_034.txt | AC | 3 ms | 1152 KB |
2_035.txt | AC | 3 ms | 1152 KB |
2_036.txt | TLE | 2153 ms | 817920 KB |
2_037.txt | WA | 3 ms | 1024 KB |
2_038.txt | WA | 3 ms | 1152 KB |
2_039.txt | WA | 4 ms | 1280 KB |
2_040.txt | MLE | 763 ms | 326144 KB |
2_041.txt | TLE | 2155 ms | 844800 KB |
2_042.txt | TLE | 2154 ms | 833280 KB |
2_043.txt | TLE | 2171 ms | 945536 KB |
2_044.txt | TLE | 2160 ms | 946560 KB |
2_045.txt | MLE | 1774 ms | 617344 KB |
2_046.txt | MLE | 1557 ms | 580992 KB |
2_047.txt | TLE | 2157 ms | 888448 KB |
2_048.txt | TLE | 2164 ms | 1023488 KB |
2_049.txt | TLE | 2168 ms | 1054336 KB |
2_050.txt | TLE | 2168 ms | 1069824 KB |