Submission #671859

# Submission time Handle Problem Language Result Execution time Memory
671859 2022-12-14T05:31:04 Z Baytoro Bank (IZhO14_bank) C++17
19 / 100
35 ms 6484 KB
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
//#define int long long
#define endl '\n'
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int INF=1e18,mod=1e9+7;
int n,m;
void get(int x){
	for(int i=0;i<m;i++)
		cout<<((x&(1<<i))?1:0);
	cout<<endl;
}
int dp[(1<<20)+5];
int ok[(1<<20)+5];
void solve(){
	memset(ok,-1,sizeof(ok));
	cin>>n>>m;
	vector<int> a(n+1),b(m+1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	for(int i=0;i<n;i++){
		for(int mask=1;mask<(1<<(m-1));mask++){
			for(int j=0;j<m;j++){
				if(mask&(1<<j)){
					//cout<<ok[(mask^(1<<j))]<<endl;
					if(ok[mask^(1<<j)]<i-1) continue;
					dp[mask]=(dp[mask^(1<<j)])+b[j];
					//get(mask);cout<<' '<<dp[mask];
					if(dp[mask]>a[i]) continue;
					ok[mask]=i-1;
					if(dp[mask]==a[i]){
						dp[mask]=0;
						ok[mask]=i;
						//get(mask);
						if(i==n-1){
							cout<<"YES\n";
							return;
						}
					}
					break;
				}
			}
		}
	}
	cout<<"NO\n";
	
}
main(){
	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}

Compilation message

bank.cpp:15:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | const int INF=1e18,mod=1e9+7;
      |               ^~~~
bank.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(){
      | ^~~~
bank.cpp: In function 'void fopn(std::string)':
bank.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4416 KB Output is correct
5 Correct 35 ms 6356 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4436 KB Output is correct
9 Correct 4 ms 6484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4416 KB Output is correct
5 Correct 35 ms 6356 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4436 KB Output is correct
9 Correct 4 ms 6484 KB Output is correct
10 Incorrect 2 ms 4308 KB Output isn't correct
11 Halted 0 ms 0 KB -