Submission #5017

# Submission time Handle Problem Language Result Execution time Memory
5017 2014-01-27T15:47:06 Z tncks0121 Bank (IZhO14_bank) C++
19 / 100
69 ms 2496 KB
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <memory.h> 
#include <math.h> 
#include <assert.h> 
#include <stack> 
#include <queue> 
#include <map> 
#include <set> 
#include <algorithm> 
#include <string> 
#include <functional> 
#include <vector> 
#include <deque> 
#include <utility> 
#include <bitset> 
#include <limits.h>  
#include <time.h>

using namespace std; 
typedef long long ll; 
typedef unsigned long long llu; 
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;

int N, M, A[20], B[20];
bool S[20][1<<20];
bool Table[20][1<<20];

int main() {
	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%d", A+i);
	for(int i = 0; i < M; i++) scanf("%d", B+i);

	for(int state = 0; state < (1<<M); state++) {
		int sum = 0;
		for(int i = 0; i < M; i++) if(state & (1<<i)) sum += B[i];
		for(int i = 0; i < N; i++) if(A[i] == sum) S[i][state] = 1;
	}

	// Table[i][state]: A[1..i] 지불, 현재 state만큼의 수표 사용
	for(int state = 0; state < (1<<M); state++) Table[0][state] = S[0][state];
	for(int i = 1; i < N; i++) {
		for(int state = 0; state < (1<<M); state++) {
			for(int p = 0; p < (1<<M) && Table[i][state]; p++) {
				if(S[i][p] && ((p & state) == p) && Table[i-1][p^state]) Table[i][state] = 1;
			}
		}
	}

	for(int state = 0; state < (1<<M); state++) if(Table[N-1][state]) return puts("YES"), 0;
	puts("NO");
	return 0;
}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:37:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < N; i++) scanf("%d", A+i);
                             ~~~~~^~~~~~~~~~~
bank.cpp:38:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < M; i++) scanf("%d", B+i);
                             ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 3 ms 592 KB Output is correct
5 Correct 69 ms 1648 KB Output is correct
6 Correct 2 ms 1648 KB Output is correct
7 Correct 2 ms 1648 KB Output is correct
8 Correct 69 ms 2496 KB Output is correct
9 Correct 69 ms 2496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 3 ms 592 KB Output is correct
5 Correct 69 ms 1648 KB Output is correct
6 Correct 2 ms 1648 KB Output is correct
7 Correct 2 ms 1648 KB Output is correct
8 Correct 69 ms 2496 KB Output is correct
9 Correct 69 ms 2496 KB Output is correct
10 Incorrect 2 ms 2496 KB Output isn't correct
11 Halted 0 ms 0 KB -