이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <set>
#include <vector>
#include <utility>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <limits.h>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;
template<typename... Args>
void print(Args&&... args){
(cout << ... << args);}
template<typename... Args>
void scan(Args&... args){
((cin >> args), ...);}
typedef long long ll;
#define X first
#define Y second
#define lenarr 1'000'000
#define inf 1'000'000'007
#define REP(x, a, b) for ( int x = a; x < b; ++x )
#define RED(x, a, b) for ( int x = a; x > b; --x )
#define FOR(x, a, b) for ( int x = a; x <= b; ++x )
#define FOD(x, a, b) for ( int x = a; x >= b; --x )
#define swap(x, y) { string _temp = x; x = y; y = _temp; }
int const MAXN = (1 << 20) + 1;
int n, m, i, j, k, Target[21], Value[21];
pair<int, int> DP[MAXN];
int main(void){
//freopen("INP.INP", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
scan(n, m);
REP(i, 1, 1 << m)
DP[i] = {-1, 0};
DP[0] = {1, 0};
FOR(i, 1, n)
scan(Target[i]);
FOR(i, 1, m)
scan(Value[i]);
REP(i, 1, 1 << m)
DP[i] = {0, 0};
DP[i] = {1, 0};
REP(i, 1, 1 << m){
FOR(j, 1, m)
if ( i & (1 << (m - j)) ){
int temp = i & ~(1 << (m - j));
if ( !DP[temp].X )
continue;
DP[i].X = DP[temp].X;
DP[i].Y = DP[temp].Y + Value[j];
if ( DP[i].Y == Target[DP[i].X] )
++DP[i].X, DP[i].Y = 0;
}
if ( DP[i].X == n + 1 ){
print("YES");
return 0;
}
} print("NO");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'void print(Args&& ...)':
bank.cpp:15:17: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
15 | (cout << ... << args);}
| ^~~~
bank.cpp: In function 'void scan(Args& ...)':
bank.cpp:18:17: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
18 | ((cin >> args), ...);}
| ^~~
# | 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... |