Submission #1730690
Source Code Expand
#include <iostream> #include <fstream> using namespace std; const int nmax=5025; int dp[2][nmax][nmax]; int a[nmax],l[nmax],r[nmax]; int n,i,j,k,ind,n1,n2,ans; bool check() { ind=1; for(j=n1;j>=1;j--) { while(ind<=n2&&l[j]+r[ind]<k) ind++; ind--; if(l[j]+r[ind]>=k-a[i]) return 1; } return 0; } int main() { freopen("data.in","r",stdin); cin>>n>>k; dp[0][0][0]=1; for(i=1;i<=n;i++) { cin>>a[i]; for(j=0;j<=k;j++) dp[0][i][j]=dp[0][i-1][j]; for(j=k-a[i];j>=0;j--) dp[0][i][j+a[i]]|=dp[0][i][j]; } dp[1][n+1][0]=1; for(i=n;i>=1;i--) { for(j=0;j<=k;j++) dp[1][i][j]=dp[1][i+1][j]; for(j=k-a[i];j>=0;j--) dp[1][i][j+a[i]]|=dp[1][i][j]; } for(i=1;i<=n;i++) { n1=n2=0; for(j=0;j<k;j++) if(dp[0][i-1][j]) l[++n1]=j; for(j=0;j<k;j++) if(dp[1][i+1][j]) r[++n2]=j; if(!check()) ++ans; } cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Go Home |
User | Bodo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1144 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 2304 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:22:33: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] freopen("data.in","r",stdin); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | WA | 2 ms | 2304 KB |
0_001.txt | WA | 2 ms | 2304 KB |
0_002.txt | WA | 2 ms | 2304 KB |
1_003.txt | WA | 2 ms | 2304 KB |
1_004.txt | WA | 2 ms | 2304 KB |
1_005.txt | WA | 2 ms | 2304 KB |
1_006.txt | WA | 2 ms | 2304 KB |
1_007.txt | WA | 2 ms | 2304 KB |
1_008.txt | WA | 2 ms | 2304 KB |
1_009.txt | WA | 2 ms | 2304 KB |
1_010.txt | WA | 2 ms | 2304 KB |
1_011.txt | WA | 2 ms | 2304 KB |
1_012.txt | WA | 2 ms | 2304 KB |
1_013.txt | WA | 2 ms | 2304 KB |
1_014.txt | WA | 2 ms | 2304 KB |
1_015.txt | WA | 2 ms | 2304 KB |
1_016.txt | WA | 2 ms | 2304 KB |
1_017.txt | WA | 2 ms | 2304 KB |