Submission #41098

#TimeUsernameProblemLanguageResultExecution timeMemory
41098HassoonyKas (COCI17_kas)C++14
100 / 100
1167 ms399356 KiB
#include<bits/stdc++.h> #include<unordered_map> using namespace std; typedef double D; typedef long long ll; typedef pair<int,int> pii; const ll mod=1e9+7; const int inf=(1<<30); const int SQ=1e6+9; const int MX=509; int n,a[MX],dp[MX][100000*2+9],sum; int DP(int x,int y){ if(x==n){ if(y==100000)return 0; return -inf; } int &ret=dp[x][y];if(ret!=-1)return ret; ret=DP(x+1,y); ret=max(ret,DP(x+1,y+a[x])+a[x]); ret=max(ret,DP(x+1,y-a[x])); return ret; } int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); sum+=a[i]; } memset(dp,-1,sizeof(dp)); cout<<sum-DP(0,100000)<<endl; }

Compilation message (stderr)

kas.cpp: In function 'int main()':
kas.cpp:24:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
kas.cpp:26:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...