이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
int INF = (int)2e9;
using namespace std;
template <class T>
istream& operator >>(istream &in, vector<T> &arr) {
for (T &cnt : arr) {
in >> cnt;
}
return in;
};
void solve() {
unsigned int n, m; cin >> n >> m;
vi a(n), b(m); cin >> a >> b;
vi used((int)2e5 + 1, 0);
for (int i = 0; i < 1 << m; ++i){
int sum = 0;
for (int j = 0; j < m; ++j){
if (i & (1 << j)){
sum += b[j];
used[sum] = 1;
}
}
sum = 0;
int ans = 0;
for (int j = 0; j < n; ++j){
sum += a[j];
if (used[sum])
ans++;
}
if (ans == n){
cout << "YES";
return;
}
used.assign((int)2e5 + 1, 0);
}
cout << "NO";
}
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#endif
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'void solve()':
bank.cpp:30:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < m; ++j){
~~^~~
bank.cpp:38:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < n; ++j){
~~^~~
bank.cpp:43:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (ans == n){
~~~~^~~~
# | 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... |