Submission #166614

#TimeUsernameProblemLanguageResultExecution timeMemory
166614Trickster은행 (IZhO14_bank)C++14
19 / 100
3 ms376 KiB
//BTTHS #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define ll long long #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using namespace std; ifstream fin("file.in"); ofstream fout("file.out"); int n, m, v[29], d[29], f[20009], sm[20009]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> v[i], v[i]+=v[i-1], f[v[i]] = v[i]; int x = n+1; for (int i = v[n]; i >= 0; i--) (f[i] == 0 ? f[i] = v[x] : f[i] = v[--x]); for (int i = 0; i < m; i++) cin >> d[i]; // for(int i = 0; i <= v[n]; i++) // cout << f[i] << " "; sort(d,d+m); sm[0] = 1; for (int i = 0; i < m; i++) { for (int h = v[n]; h >= 0; h--) { if (sm[h]) { if ((f[h] == f[d[i]] && (f[h+d[i]] == f[h] || f[h+d[i]-1] == f[h])) || (f[h]!=f[h+1] && f[h+d[i]] == f[h+1])) sm[h+d[i]] = 1; } } } // for (int i = 0; i <= v[n]; i++) // { // cout << i << ": " << sm[i] << "\n"; // } cout << (sm[v[n]] == 1 ? "YES" : "NO"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...