Submission #1443793
Source Code Expand
#include<bits/stdc++.h> using namespace std; int N,K; int ans = 0; vector<int> V; int dp[5010][10010] = {1}; int main() { scanf("%d%d",&N,&K); for(int i = 0; i < N; i++) { int a; scanf("%d",&a); if(a <= K) { V.push_back(a); } } N = V.size(); for(int i = 0; i < N; i++) { for(int j = 0; j <= K * 2; j++) { if(dp[i][j] != 0) { dp[i + 1][j] += dp[i][j]; if(i + V[i] <= K * 2)dp[i + 1][j + V[i]] += dp[i][j]; } } } for(int i = 0; i < N; i++) { int now = V[i]; int mem[5010] = {0}; for(int j = 0; j <= K; j++) { if(j == K)ans++; if(dp[N][j] - mem[j] > 0 && dp[N][j + now] > 0) { mem[j + now] += dp[N][j] - mem[j]; mem[j] += dp[N][j] - mem[j]; if(j >= K - now) { break; } } } } printf("%d\n",ans); }
Submission Info
Submission Time | |
---|---|
Task | D - No Need |
User | unit |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1130 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&N,&K); ^ ./Main.cpp:15:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&a); ^ g++: internal compiler error: File size limit exceeded (program as) Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.