이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
#define f first
#define s second
#define int long long
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
int n,m,a[N],b[N],sum,fix[N];
vector <int> v[N],v1,v2;
int msk,msk1;
main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
for (int i = 1; i <= n; i++) {
cin>>a[i];
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= m ;i++) {
cin>>b[i];
}
sort(b + 1, b + m + 1);
for (int i = 1; i < (1<<m); i++) {
int sum = 0;
for (int j = 0; j < m; j++) {
if ((1<<j) & i) sum += b[j + 1];
}
if (sum <= 1000) v[sum].pb(i);
}
v1.pb(0);
for (int i = 1; i <= n; i++) {
v2.clear();
for (int j = 0; j < v[a[i]].size(); j++) { msk = v[a[i]][j];
for (int j1 = 0; j1 < v1.size(); j1++) { msk1 = v1[j1];
if (!(msk & msk1) && !fix[msk | msk1]) v2.pb(msk|msk1);
}
}
for (int i = 0; i < v2.size(); i++) {
fix[v2[i]] = 0;
}
v1 = v2;
}
if (v1.size()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main() {
| ^~~~
bank.cpp: In function 'int main()':
bank.cpp:32:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int j = 0; j < v[a[i]].size(); j++) { msk = v[a[i]][j];
| ~~^~~~~~~~~~~~~~~~
bank.cpp:33:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int j1 = 0; j1 < v1.size(); j1++) { msk1 = v1[j1];
| ~~~^~~~~~~~~~~
bank.cpp:37:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i = 0; i < v2.size(); i++) {
| ~~^~~~~~~~~~~
# | 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... |