이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pob pop_back
//#define int long long
#define int2 __int128_t
#define Shrek_Crush228 ios_base::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nep next_permutation
#define sigma signed
#define pii pair <int, int>
using namespace std;
string alp = "abcdefghijklmnopqrstuvwxyz";
string ae = "aoeiuy";
string nums = "123456789";
const int N = 1e3 + 123;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int MOD1 = 998244353;
const long long maxsum = 1e14;
int a[N], b[N], c[N], l, r, n, k, m, w, sum, sum1, y, ans1, mx = -inf, mn = inf, ind, ind1, pref[N], suf[N], nt[N];
string s, s1;
int cnt1, cnt2, cnt3;
vector <int> v;
void rec( int need, int i = 1, int sum = 0, string ss = "" )
{
if( sum > need ) return;
if( sum == need )
{
s = ss;
return;
}
if( i > m ) return;
if( !nt[i] ) rec( need, i + 1, sum + b[i], ss + '1' );
rec( need, i + 1, sum, ss + '0' );
}
void solve()
{
cin >> n >> m;
FOR( i, 1, n, 1 ) cin >> a[i];
FOR( i, 1, m, 1 ) cin >> b[i];
FOR( i, 1, n, 1 )
{
if( c[i] ) continue;
s = "";
rec( a[i] );
if( s.size() == 0 )
{
if( i == 1 )
{
cout << "NO\n";
return;
}
FOR( j, 1, m, 1 ) nt[j] = 0;
rec( a[i] );
//cout << s;
if( s.size() == 0 )
{
cout << "NO\n";
return;
}
FOR( pos, 0, s.size() - 1, 1 )
{
if( s[pos] == '1' ) nt[pos + 1] = 1;
}
c[i] = 1;
i = 0;
}
FOR( pos, 0, s.size() - 1, 1 )
{
if( s[pos] == '1' ) nt[pos + 1] = 1;
}
}
cout << "YES";
}
sigma main()
{
//freopen("rmq.in", "r", stdin);
//freopen("rmq.out", "w", stdout);
Shrek_Crush228
int test = 1;
if( !test ) cin >> test;
while( test -- )
{
solve();
}
}
// solved by KluydQ
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'void solve()':
bank.cpp:16:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | #define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
......
89 | FOR( pos, 0, s.size() - 1, 1 )
| ~~~~~~~~~~~~~~~~~~~~
bank.cpp:89:4: note: in expansion of macro 'FOR'
89 | FOR( pos, 0, s.size() - 1, 1 )
| ^~~
bank.cpp:16:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | #define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
......
96 | FOR( pos, 0, s.size() - 1, 1 )
| ~~~~~~~~~~~~~~~~~~~~
bank.cpp:96:3: note: in expansion of macro 'FOR'
96 | FOR( pos, 0, s.size() - 1, 1 )
| ^~~
# | 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... |