Submission #1168356
Source Code Expand
//Andrew Yang #include <iostream> #include <stdio.h> #include <sstream> #include <fstream> #include <string> #include <string.h> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdio> #include <climits> using namespace std; #define FOR(index, start, end) for(int index = start; index < end; index++) #define RFOR(index, start, end) for(int index = start; index > end; index--) #define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++) #define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++) #define INF 1000000000 #define M 1000000007 typedef long long ll; typedef pair<int, int> pii; int a[5001]; int dp[5001]; int necessary[5001]; int main(void) { int n, k; scanf("%d%d", &n, &k); FOR(i, 0, n) { scanf("%d", &a[i]); } FOR(i, 0, n) { memset(dp, 0, sizeof(dp)); dp[0] = 1; FOR(j, 0, i) { if (a[j] >= k) { continue; } RFOR(x, k - 1, a[k]) { if (dp[x - a[j]]) { dp[x] = 1; if (x < k && x >= k - a[i]) { necessary[i] = true; } } } } FOR(j, i + 1, n) { if (a[j] >= k) { continue; } RFOR(x, k - 1, a[k]) { if (dp[x - a[j]]) { dp[x] = 1; if (x < k && x >= k - a[i]) { necessary[i] = true; } } } } } int ans = 0; FOR(i, 0, n) { if (!necessary[i]) { ans++; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - No Need |
User | GreatWallChina |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1710 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:40:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &k); ^ ./Main.cpp:43:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^
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 | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 70 ms | 256 KB |
1_009.txt | AC | 69 ms | 256 KB |
1_010.txt | WA | 2 ms | 256 KB |
1_011.txt | WA | 1 ms | 256 KB |
1_012.txt | WA | 1 ms | 256 KB |
1_013.txt | WA | 1 ms | 256 KB |
1_014.txt | WA | 1 ms | 256 KB |
1_015.txt | AC | 83 ms | 256 KB |
1_016.txt | AC | 1 ms | 256 KB |
1_017.txt | AC | 1 ms | 256 KB |
1_018.txt | AC | 1 ms | 256 KB |
1_019.txt | WA | 2 ms | 256 KB |
1_020.txt | AC | 2 ms | 256 KB |
1_021.txt | AC | 19 ms | 256 KB |
1_022.txt | AC | 7 ms | 256 KB |
1_023.txt | AC | 2 ms | 256 KB |
1_024.txt | WA | 2 ms | 256 KB |
1_025.txt | WA | 18 ms | 256 KB |
2_026.txt | WA | 1 ms | 256 KB |
2_027.txt | AC | 1 ms | 256 KB |
2_028.txt | AC | 1 ms | 256 KB |
2_029.txt | TLE | 2103 ms | 256 KB |
2_030.txt | TLE | 2103 ms | 256 KB |
2_031.txt | WA | 21 ms | 256 KB |
2_032.txt | WA | 21 ms | 384 KB |
2_033.txt | WA | 21 ms | 256 KB |
2_034.txt | WA | 21 ms | 256 KB |
2_035.txt | WA | 21 ms | 256 KB |
2_036.txt | TLE | 2103 ms | 256 KB |
2_037.txt | AC | 2 ms | 256 KB |
2_038.txt | AC | 2 ms | 256 KB |
2_039.txt | AC | 2 ms | 256 KB |
2_040.txt | WA | 22 ms | 256 KB |
2_041.txt | TLE | 2103 ms | 256 KB |
2_042.txt | TLE | 2103 ms | 256 KB |
2_043.txt | TLE | 2103 ms | 256 KB |
2_044.txt | WA | 67 ms | 256 KB |
2_045.txt | TLE | 2103 ms | 256 KB |
2_046.txt | WA | 114 ms | 256 KB |
2_047.txt | WA | 114 ms | 256 KB |
2_048.txt | WA | 115 ms | 256 KB |
2_049.txt | TLE | 2103 ms | 256 KB |
2_050.txt | WA | 93 ms | 256 KB |