# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039500 | coolsentenceidontremember | Bank (IZhO14_bank) | C++17 | 86 ms | 8792 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define ld long double
#define ff first
#define ss second
#define db double
#define time_begin() auto begin = chrono::high_resolution_clock::now()
#define time_end() auto end = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end-begin); auto sec = elapsed.count() * 1e-9; cerr << "\n\nExecution time: " << sec << " seconds";
#define check_time() cerr << "\nStatus : "; if (sec>1) cerr << "Time Limit Exceeded 1!!!1!111"; else cerr << "You good brother"
using namespace std;
void setIO(string s = ""){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
if (!s.empty()){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
}
int main(){
setIO();
int n, m;
cin >> n >> m;
int ppl[n], bank[m];
for (int &i : ppl) cin >> i;
for (int &i : bank) cin >> i;
vector<int> left(1<<m, 0), cover(1<<m, -1);
cover[0] = 0;
for (int mask = 0; mask < (1<<m); mask++){
for (int b = 0; b < m; b++){
if (mask & (1<<b)){
int prev = mask^(1<<b);
if (cover[prev] == -1) continue;
int target = ppl[cover[prev]];
int cur_tenge = left[prev]+bank[b];
if (cur_tenge < target){
left[mask] = cur_tenge;
cover[mask] = cover[prev];
} else if (cur_tenge==target){
cover[mask] = cover[prev]+1;
left[mask] = 0;
}
}
}
if (cover[mask] == n){
cout << "YES";
return 0;
}
}
return cout << "NO", 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |