제출 #1288195

#제출 시각아이디문제언어결과실행 시간메모리
1288195eri16은행 (IZhO14_bank)C++20
0 / 100
1 ms716 KiB
#include <bits/stdc++.h>

using namespace std;

int main(){
    
    int n,m;
    
    cin>>n>>m;
    
    vector <int> v1(n),v2(n);
    
    for (int i=0; i<n; i++){cin>>v1[i];}
    for (int i=0; i<m; i++){cin>>v2[i];}
    
    int dp1[20005]={0};
    int dp2[20005]={0};
    
    dp1[0]=1;
    dp2[0]=1;
    
    if (n>m){cout<<"NO";}
    else{
        
        for (int i=0; i<n; i++){
            for (int j=20000-v1[i]; j>=0; j--){
                if (dp1[j]==1){dp1[j+v1[i]]=1;}
            }
        }
    
        for (int i=0; i<n; i++){
            for (int j=20000-v2[i]; j>=0; j--){
                if (dp2[j]==1){dp2[j+v2[i]]=1;}
            }
        }    
        
        int ans=1;
        
        for (int i=0; i<=20005; i++){
            if (dp1[i]==1 && dp2[i]==0){ans=0;}
        }
        
        if (ans==1){cout<<"YES";}
        else{cout<<"NO";}
    }
}

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

bank.cpp: In function 'int main()':
bank.cpp:40:22: warning: iteration 20005 invokes undefined behavior [-Waggressive-loop-optimizations]
   40 |             if (dp1[i]==1 && dp2[i]==0){ans=0;}
      |                 ~~~~~^
bank.cpp:39:24: note: within this loop
   39 |         for (int i=0; i<=20005; 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...