제출 #17911

#제출 시각아이디문제언어결과실행 시간메모리
17911Adilkhan은행 (IZhO14_bank)C++98
0 / 100
4 ms696 KiB
#include <bits/stdc++.h> #define pb push_back #define endl "\n" #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define fname "" #define sz(x) (int)(x.size()) typedef long long ll; using namespace std; const ll N = (ll)(5e5) + 322; const ll INF = (ll)(1e9); const ll mod = (ll)(1e9) + 7; const double eps = 1e-9; int n, m, x, nz, sum; vector <int> a, b; void calc(int pmsk, int x) { if (x == n - 1) { sum = 0; for (int i = 0; i < m; ++i) { if (!(pmsk & (1 << i))) { sum += b[i]; } } if (sum == a[x]) puts("YES"); exit(0); return; } for (int mask = 0; mask < (1 << m); ++mask) { if ((mask & pmsk)) {continue;} // if (m - (__builtin_popcount(mask) + __builtin_popcount(pmsk)) < (n - x)) {continue;} sum = 0; for (int i = 0; i < m; ++i) { if (mask & (1 << i)) { sum += b[i]; } } if (sum == a[x]) { calc(pmsk ^ mask, x + 1); } } } int main () { //ios_base :: sync_with_stdio (false); cin.tie(0); //freopen(fname".in", "r", stdin); //freopen(fname".out", "w", stdout); scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d", &x); a.pb(x); } for (int i = 1; i <= m; ++i) { scanf("%d", &x); b.pb(x); } if (n > m) { puts("NO"); return 0; } if (n == m) { sort(all(a)); sort(all(b)); if (a == b) { puts("YES"); }else { puts("NO"); } return 0; } sort(all(a)); reverse(all(a)); calc(0, 0); puts("NO"); return 0; }

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

bank.cpp: In function 'void calc(int, int)':
bank.cpp:33:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (sum == a[x])
   ^~
bank.cpp:34:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    puts("YES"); exit(0);
                 ^~~~
bank.cpp: In function 'int main()':
bank.cpp:56: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:58:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x); a.pb(x);
   ~~~~~^~~~~~~~~~
bank.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x); b.pb(x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...