Submission #1443783
Source Code Expand
#include <iostream> #include <set> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) using namespace std; typedef long long ll; ll N, K, A[5000]; char dp[5001][5001]; set<ll> st[5000]; ll cnt[5000]; ll dfs(ll n, ll k, set<ll> &st) { if(n == 0 || k == 0) return 1; ll ret = 0; if(!st.count(n - 1)) { if(dp[n][k] & 2) st.insert(n - 1); if(dp[n][k] & 1) ret += dfs(n - 1, k, st); if(dp[n][k] & 2) ret += dfs(n - 1, k - A[n - 1], st); } return ret; } int main(void) { cin >> N >> K; REP(i, 0, N) cin >> A[i]; REP(i, 0, N + 1) REP(j, 0, K + 1) dp[i][j] = 0; dp[0][0] = 1; REP(i, 0, N) REP(j, 0, K) if(dp[i][j]) { dp[i + 1][j] |= 1; if(j + A[i] < K) dp[i + 1][j + A[i]] |= 2; } REP(i, 0, K) cnt[i] = 0; REP(i, 0, K) if(dp[N][i]) cnt[i] = dfs(N, i, st[i]); ll ans = N; REP(i, 0, N) { bool f = 0; REP(j, 0, K) if(dp[N][j] && (!st[j].count(i) || cnt[j] > 1) && j + A[i] >= K) f = 1; if(f) ans--; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - No Need |
User | kshinya |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1041 Byte |
Status | WA |
Exec Time | 2144 ms |
Memory | 669824 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 | 512 KB |
0_001.txt | AC | 1 ms | 512 KB |
0_002.txt | AC | 1 ms | 512 KB |
1_003.txt | AC | 1 ms | 512 KB |
1_004.txt | AC | 1 ms | 512 KB |
1_005.txt | AC | 1 ms | 512 KB |
1_006.txt | WA | 2 ms | 768 KB |
1_007.txt | WA | 2 ms | 768 KB |
1_008.txt | WA | 33 ms | 11648 KB |
1_009.txt | AC | 33 ms | 11648 KB |
1_010.txt | AC | 3 ms | 4096 KB |
1_011.txt | AC | 2 ms | 3968 KB |
1_012.txt | AC | 3 ms | 4096 KB |
1_013.txt | AC | 2 ms | 3968 KB |
1_014.txt | AC | 2 ms | 3968 KB |
1_015.txt | AC | 29 ms | 7552 KB |
1_016.txt | AC | 1 ms | 512 KB |
1_017.txt | WA | 1 ms | 640 KB |
1_018.txt | WA | 1 ms | 640 KB |
1_019.txt | AC | 4 ms | 4096 KB |
1_020.txt | AC | 3 ms | 4096 KB |
1_021.txt | AC | 13 ms | 5632 KB |
1_022.txt | AC | 5 ms | 1920 KB |
1_023.txt | AC | 2 ms | 1152 KB |
1_024.txt | AC | 11 ms | 6144 KB |
1_025.txt | AC | 15 ms | 6784 KB |
2_026.txt | AC | 1 ms | 512 KB |
2_027.txt | WA | 3 ms | 1280 KB |
2_028.txt | WA | 3 ms | 1280 KB |
2_029.txt | TLE | 2144 ms | 655488 KB |
2_030.txt | TLE | 2142 ms | 669824 KB |
2_031.txt | AC | 52 ms | 24960 KB |
2_032.txt | AC | 8 ms | 24576 KB |
2_033.txt | AC | 50 ms | 24960 KB |
2_034.txt | AC | 8 ms | 24576 KB |
2_035.txt | AC | 8 ms | 24576 KB |
2_036.txt | TLE | 2124 ms | 365568 KB |
2_037.txt | AC | 4 ms | 1792 KB |
2_038.txt | WA | 5 ms | 2048 KB |
2_039.txt | AC | 5 ms | 1920 KB |
2_040.txt | AC | 433 ms | 26368 KB |
2_041.txt | TLE | 2122 ms | 322816 KB |
2_042.txt | TLE | 2127 ms | 402816 KB |
2_043.txt | TLE | 2120 ms | 293632 KB |
2_044.txt | TLE | 2122 ms | 334976 KB |
2_045.txt | TLE | 2050 ms | 174592 KB |
2_046.txt | TLE | 2121 ms | 311936 KB |
2_047.txt | TLE | 2130 ms | 470528 KB |
2_048.txt | TLE | 2130 ms | 464512 KB |
2_049.txt | TLE | 2129 ms | 436864 KB |
2_050.txt | TLE | 2126 ms | 401152 KB |