제출 #1129209

#제출 시각아이디문제언어결과실행 시간메모리
1129209wafaa_s_473은행 (IZhO14_bank)C++20
0 / 100
2 ms324 KiB
#include <bits/stdc++.h> #define el <<'\n' ; #define Lol ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define all(v) v.begin() , v.end() #define rall(v) v.rbegin() , v.rend() #define sz(s) (int)s.size() #define int long long /* * ياا مسهل الاحوال */ using namespace std; void _3K_W_RABK_YFK(){ int n , m; cin>>n>>m ; vector<int>a(n) , b(m) , pre(1); for( auto &i:a ) cin>>i , pre.push_back(pre.back() + i); for( auto &i:b ) cin>>i ; vector<int>dp(1 << m) ; dp[0] = 0 ; int idx = 0 ; for( int msk = 1 ; msk < (1 << m) ; ++msk ){ int sum = 0 ; for( int i = 0 ; i < m ; ++i ) if( msk & (1 << i) ) sum += b[i] ; for( int i = 0 ; i < m ; ++i ){ if( msk & (1 << i) ){ int prv = dp[msk ^ (1 << i)] ; dp[msk] = max(dp[msk] , prv) ; if( prv < n and a[prv] == sum - pre[prv] ) dp[msk] = max(dp[msk] , prv + 1) ; } } idx = max(idx, dp[msk]) ; // cout<<msk<<' '<<dp[msk]<<endl; } cout<<(idx == n ? "YES" : "NO") ; } int32_t main() { Lol #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t=1 ;// cin>>t ; for( int i=1; i<=t; ++i ){ _3K_W_RABK_YFK(); } return 0; } /* practice makes PERFECT */

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

bank.cpp: In function 'int32_t main()':
bank.cpp:43:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:44:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  freopen("output.txt", "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...