제출 #1001490

#제출 시각아이디문제언어결과실행 시간메모리
1001490reginox은행 (IZhO14_bank)C++17
100 / 100
65 ms4688 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> #define task "test" using namespace std; int a[20], b[20], dp[(1<<20) +2]; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); int n,m,max1,sum,i,j; cin>>n>>m; for(i=0;i<n;i++) { cin>>a[i]; if(i) a[i]+=a[i-1]; } for (i=0;i<m;i++) cin>>b[i]; for(i=0;i<(1<<m);i++) { max1=-1;sum=0; for(j=0;j<m;j++){ if(i&(1<<j)){ sum+=b[j]; max1=max(max1,dp[i^(1<<j)]); } } dp[i]=max1; if(sum==a[max1+1]) dp[i]++; if(dp[i]==n-1){ cout<<"YES"; return 0; } } cout <<"NO"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...