제출 #879813

#제출 시각아이디문제언어결과실행 시간메모리
879813The_Samurai은행 (IZhO14_bank)C++17
44 / 100
1 ms356 KiB
// I stand with PALESTINE //#pragma GCC optimize("Ofast,O3") //#pragma GCC target("avx,avx2") #include "bits/stdc++.h" using namespace std; using ll = long long; void solve() { int n, m; cin >> m >> n; vector<int> a(n), b(m); for (int &x: b) cin >> x; for (int &x: a) cin >> x; auto solve = [&]() -> void { for (int i = 0; i < m; i++) { vector<int> came(b[i] + 1, -1); came[0] = 0; for (int j = 0; j < a.size(); j++) { for (int x = b[i]; x >= a[j]; x--) { if (came[x] == -1 and came[x - a[j]] != -1) { came[x] = a[j]; } } } if (came[b[i]] == -1) return; int x = b[i]; while (x != 0) { a.erase(find(a.begin(), a.end(), came[x])); x -= came[x]; } // for (int x: a) cout << x << ' '; // cout << endl; } cout << "YES"; exit(0); }; for (int i = 0; i < 4; i++) { if (i & 1) sort(a.begin(), a.end()); else sort(a.rbegin(), a.rend()); if (i & 2) sort(b.begin(), b.end()); else sort(b.rbegin(), b.rend()); solve(); } cout << "NO"; } int main() { cin.tie(0)->sync_with_stdio(false); #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; // cin >> q; while (q--) { solve(); cout << '\n'; } }

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

bank.cpp: In lambda function:
bank.cpp:23:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for (int j = 0; j < a.size(); j++) {
      |                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...