제출 #383345

#제출 시각아이디문제언어결과실행 시간메모리
383345Iwanttobreakfree은행 (IZhO14_bank)C++17
0 / 100
1 ms364 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m,sum; cin>>n>>m; vector<int> sal(n); vector<int> bank(m); for(int i=0;i<n;i++)cin>>sal[i]; for(int i=0;i<m;i++)cin>>bank[i]; for(int i=0;i<n;i++)sum+=sal[i]; for(int j=0;j<m;j++)sum-=bank[j]; if(sum>0)cout<<"NO\n"; else { sort(sal.rbegin(),sal.rend()); sort(bank.rbegin(),bank.rend()); vector<vector<int> > DP(n,vector<int>(m)); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ DP[i][j]=sal[i]; if(sal[i]<bank[j])continue; else { for(int q=0;q<j;q++){ int x=DP[i][q]-bank[j]; if(x<0)x*=-1; DP[i][j]=min(x,DP[i][j]); } } } } bool pos=true; for(int i=0;i<n;i++){ if(DP[i][m-1]!=0){ pos=false; break; } } if(pos)cout<<"YES\n"; else cout<<"NO\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:14:2: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |  if(sum>0)cout<<"NO\n";
      |  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...