제출 #846026

#제출 시각아이디문제언어결과실행 시간메모리
846026GoldLight은행 (IZhO14_bank)C++17
19 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; void fast(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);} const int N=2e4; int main(){ fast(); int n, m; cin>>n>>m; int a[n+1], b[m+1]; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=m; i++) cin>>b[i]; if(n==1){ vector<bool> dp(N+1); dp[0]=true; for(int i=1; i<=m; i++){ for(int j=a[1]; j>=1; j--){ if(j>=b[i] && dp[j-b[i]]) dp[j]=true; } } if(dp[a[1]]) cout<<"YES"; else cout<<"NO"; } } /* #define int long long const int INF=-1e18; struct info{int x, y, z;}; bool cmp(info a, info b){ if(a.y!=b.y) return a.y>b.y; return a.z<b.z; } signed main(){ fast(); vector<info> v; int n, m=0; cin>>n; for(int i=1; i<=n; i++){ int x, y, z; cin>>x>>y>>z; v.push_back({x, y, -z}); m+=x; } cin>>n; for(int i=1; i<=n; i++){ int x, y, z; cin>>x>>y>>z; v.push_back({-x, y, z}); } sort(v.begin(), v.end(), cmp); vector<int> dp(m+1, INF); dp[0]=0; for(auto [x, y, z]:v){ vector<int> dp2=dp; for(int i=0; i<=m; i++){ int next=i+x; if(next>=0 && next<=m && dp[i]!=INF){ dp2[next]=max(dp2[next], dp[i]+z); } } dp=dp2; } cout<<*max_element(dp.begin(), dp.end()); } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...