제출 #855887

#제출 시각아이디문제언어결과실행 시간메모리
855887bestrazhuxp은행 (IZhO14_bank)C++17
100 / 100
109 ms8652 KiB
#include <bits/stdc++.h> #define ll long long #define se second #define fi first #define pb push_back #define all(x) (x).begin() , (x).end() #define sz(x) (int)(x).size() #define BIT(x , i) ((x) >> (i) & 1) #define MASK(i) (1LL << (i)) #define name "1" #define task "" using namespace std; const int inf = 1e9 + 7; const ll linf = 1ll * inf * inf; const int mod = 1e9 + 7; const int maxn = 1e5 + 2; void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}} int n; int m; int a[20]; int b[20]; int f[1 << 20]; int rem[1 << 20]; bool maximize(int &x , int y) { if(x < y) return x = y, 1; return 0; } int main() { file(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0 ; i < n; i++) cin >> a[i]; for(int i = 0 ; i < m; i++) cin >> b[i]; memset(f , -1, sizeof f); f[0] = 0; for(int s = 0 ; s < MASK(m) ; s++) { for(int i = 0; i < m; i++) { if(!BIT(s , i)) continue; int prev = s ^ MASK(i); if(f[prev] < 0) continue; int cur = a[f[prev]]; if(rem[prev] + b[i] < cur) { f[s] = f[prev]; rem[s] = rem[prev] + b[i]; } else if(rem[prev] + b[i] == cur) { f[s] = f[prev] + 1; rem[s] = 0; } if(f[s] == n) return cout << "YES" , 0; } } cout << "NO"; }

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

bank.cpp: In function 'void file()':
bank.cpp:20:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:20:82: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:20:151: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                                                                                                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:20:185: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".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...