제출 #5027

#제출 시각아이디문제언어결과실행 시간메모리
5027ainta은행 (IZhO14_bank)C++98
100 / 100
180 ms560 KiB
#pragma warning(disable:4996) #include<stdio.h> #include<algorithm> using namespace std; int n, m, a[20], b[20], o[1010]; bool v[20]; bool DFS(int x, int C); bool Do(int x, int S, int p, int C, int cnt){ int i; if (!S){ if (DFS(x + 1, C - cnt))return true; return false; } if (cnt == C - (n - x) * 2 + 2)return false; for (i = p; i < m; i++){ if (!v[i] && S >= b[i]){ v[i] = true; if (Do(x, S - b[i], i + 1, C, cnt + 1))return true; v[i] = false; } } return false; } bool DFS(int x, int C){ if (x == n){ return true; } if ((n - x) * 2 > C)return false; return Do(x, a[x], 0, C, 0); } int main(){ int i, j; scanf("%d%d", &n, &m); int t; for (i = 0; i < n; i++){ scanf("%d", &t); o[t]++; } for (i = 0; i < m; i++){ scanf("%d", &t); o[t]--; } n = 0, m = 0; for (i = 1; i <= 1000; i++){ if (o[i]){ while (o[i] > 0)a[n++] = i, o[i]--; while (o[i] < 0)b[m++] = i, o[i]++; } } printf(DFS(0, m)?"YES" : "NO"); }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
bank.cpp: In function 'int main()':
bank.cpp:32:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
bank.cpp:33: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:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t);
   ~~~~~^~~~~~~~~~
bank.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...