Submission #3229933
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll #define REP(i,n) for(int i=0;i<n;++i) #define SORT(name) sort(name.begin(), name.end()) #define ZERO(p) memset(p, 0, sizeof(p)) #define MINUS(p) memset(p, -1, sizeof(p)) #if 1 # define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__) #else # define DBG(fmt, ...) #endif const ll LLINF = (1LL<<60); const int INF = (1LL<<30); const double DINF = std::numeric_limits<double>::infinity(); const int MOD = 1000000007; #define MAX_N 5010 bool dp[MAX_N][MAX_N] = {}; bool maked[MAX_N][MAX_N] = {}; // グループ内の数の組み合わせで i 抜きで j が作れるなら true int N, K; int A[MAX_N]; map<int, bool> isChecked; map<int, int> valToInd; // 今 i を見ていて、現在の数が j のとき // ただし A[skip] は加算せずにとばす void dfs(int i, int j, int skip) { if(i >= N) { return; } if(dp[i][j]) { return; } dfs(i+1, j, skip); if(i != skip && j + A[i] < K) { maked[skip][j + A[i]] = true; dfs(i+1, j + A[i], skip); valToInd[A[i]] = i; } dp[i][j] = true; } signed main() { cin >> N >> K; REP(i, N) { cin >> A[i]; } REP(i, N) { if(isChecked.count(A[i]) != 0) { continue; } ZERO(dp); dfs(0, 0, i); isChecked[A[i]] = true; } ll ans = N; REP(i, N) { for(int j = K - A[i]; j < K; ++j) { int ind = valToInd[A[i]]; if( j <= 0 || maked[ind][j]) { ans--; break; } } } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - No Need |
User | VTR |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1675 Byte |
Status | WA |
Exec Time | 2104 ms |
Memory | 43648 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 | 13 ms | 26752 KB |
0_001.txt | AC | 14 ms | 26752 KB |
0_002.txt | AC | 16 ms | 26752 KB |
1_003.txt | AC | 8 ms | 26752 KB |
1_004.txt | AC | 8 ms | 26752 KB |
1_005.txt | AC | 8 ms | 26752 KB |
1_006.txt | AC | 18 ms | 26752 KB |
1_007.txt | AC | 18 ms | 26752 KB |
1_008.txt | WA | 8 ms | 26880 KB |
1_009.txt | AC | 8 ms | 26880 KB |
1_010.txt | AC | 8 ms | 26880 KB |
1_011.txt | AC | 8 ms | 26880 KB |
1_012.txt | AC | 8 ms | 26880 KB |
1_013.txt | AC | 8 ms | 26880 KB |
1_014.txt | AC | 820 ms | 26880 KB |
1_015.txt | TLE | 2093 ms | 28672 KB |
1_016.txt | AC | 22 ms | 26880 KB |
1_017.txt | AC | 24 ms | 26880 KB |
1_018.txt | AC | 23 ms | 26880 KB |
1_019.txt | AC | 28 ms | 26880 KB |
1_020.txt | WA | 23 ms | 26880 KB |
1_021.txt | AC | 627 ms | 27520 KB |
1_022.txt | AC | 387 ms | 27392 KB |
1_023.txt | AC | 182 ms | 27136 KB |
1_024.txt | AC | 38 ms | 26880 KB |
1_025.txt | AC | 44 ms | 26880 KB |
2_026.txt | AC | 8 ms | 26752 KB |
2_027.txt | AC | 22 ms | 26880 KB |
2_028.txt | AC | 24 ms | 26880 KB |
2_029.txt | WA | 217 ms | 27264 KB |
2_030.txt | AC | 211 ms | 27264 KB |
2_031.txt | AC | 10 ms | 27264 KB |
2_032.txt | AC | 11 ms | 27264 KB |
2_033.txt | AC | 9 ms | 27264 KB |
2_034.txt | AC | 9 ms | 27264 KB |
2_035.txt | TLE | 2104 ms | 27264 KB |
2_036.txt | TLE | 2103 ms | 27520 KB |
2_037.txt | AC | 39 ms | 26880 KB |
2_038.txt | AC | 37 ms | 26880 KB |
2_039.txt | AC | 37 ms | 26880 KB |
2_040.txt | AC | 336 ms | 43648 KB |
2_041.txt | TLE | 2103 ms | 27392 KB |
2_042.txt | TLE | 2103 ms | 27392 KB |
2_043.txt | TLE | 2103 ms | 27136 KB |
2_044.txt | TLE | 2103 ms | 27264 KB |
2_045.txt | TLE | 2103 ms | 27264 KB |
2_046.txt | TLE | 2103 ms | 27264 KB |
2_047.txt | TLE | 2103 ms | 27264 KB |
2_048.txt | TLE | 2103 ms | 27264 KB |
2_049.txt | TLE | 2104 ms | 27264 KB |
2_050.txt | TLE | 2104 ms | 27264 KB |