답안 #390700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390700 2021-04-16T15:20:12 Z ahmet 은행 (IZhO14_bank) C++14
19 / 100
25 ms 360 KB
#include <bits/stdc++.h>
using namespace std;
#define zaman cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))	
#define endl '\n'
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair
const int mx=1e6+6;
int a[22],b[22],dp[mx];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;cin >> n >> m;
	ref(i,1,n)cin >> a[i];
	ref(i,1,m)cin >> b[i];
	sort(b+1,b+m+1);
	dp[0]=1;
	for(int i=m;i>0;--i){
		int bank=b[i];
		for(int s=1e6;s>0;--s){
			if(s-bank<0)break;
			if(dp[s-bank]){dp[s]=1;}
		}
	}
	if(dp[a[1]])cout<<"YES"<<endl;
	else cout << "NO"<<endl;	
}	
	

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:5:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
      |                                   ^
bank.cpp:16:2: note: in expansion of macro 'ref'
   16 |  ref(i,1,n)cin >> a[i];
      |  ^~~
bank.cpp:5:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
      |                                   ^
bank.cpp:17:2: note: in expansion of macro 'ref'
   17 |  ref(i,1,m)cin >> b[i];
      |  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 12 ms 332 KB Output is correct
4 Correct 17 ms 336 KB Output is correct
5 Correct 25 ms 332 KB Output is correct
6 Correct 12 ms 328 KB Output is correct
7 Correct 13 ms 204 KB Output is correct
8 Correct 22 ms 332 KB Output is correct
9 Correct 22 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 332 KB Output is correct
2 Correct 12 ms 340 KB Output is correct
3 Correct 12 ms 336 KB Output is correct
4 Incorrect 11 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 19 ms 332 KB Output is correct
3 Correct 16 ms 360 KB Output is correct
4 Correct 16 ms 336 KB Output is correct
5 Incorrect 19 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 12 ms 332 KB Output is correct
4 Correct 17 ms 336 KB Output is correct
5 Correct 25 ms 332 KB Output is correct
6 Correct 12 ms 328 KB Output is correct
7 Correct 13 ms 204 KB Output is correct
8 Correct 22 ms 332 KB Output is correct
9 Correct 22 ms 332 KB Output is correct
10 Correct 12 ms 332 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 12 ms 336 KB Output is correct
13 Incorrect 11 ms 332 KB Output isn't correct
14 Halted 0 ms 0 KB -