제출 #1056476

#제출 시각아이디문제언어결과실행 시간메모리
1056476vjudge1은행 (IZhO14_bank)C++17
100 / 100
77 ms27280 KiB
#include<bits/stdc++.h> using namespace std; #define task "rbp" #define ii pair<int,int> #define fi first #define se second #define int long long #define ld double #define mp make_pair #define lg2 21 #define iii pair<int,ii> #define iiii pair<ii,ii> #define fii fi.fi #define fis fi.se #define sfi se.fi #define see se.se #define base 29 int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; const int maxn=20+5; const int mod=998244353; const int maxi=1000; const int them=1e6; int n,m,a[maxn],b[maxn],vis[(1<<21)]; ii dp[(1<<21)]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout);} cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; dp[0]={1,0}; vis[0]=1; for(int i=1;i<(1<<m);i++) { for(int j=0;j<m;j++) { if(i&(1<<j)&&vis[i^(1<<j)]) { ii d=dp[i^(1<<j)]; d.se+=b[j]; if(d.se<a[d.fi]) { dp[i]=d; vis[i]=1; } else if(d.se==a[d.fi]) { vis[i]=1; if(d.fi+1>n) { cout<<"YES"; return 0; } dp[i]={d.fi+1,0}; } } } } cout<<"NO"; }

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

bank.cpp: In function 'int main()':
bank.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     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...