結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-09 00:43:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 775 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 32,000 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:29:36 |
合計ジャッジ時間 | 992 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 12 |
ソースコード
/* -*- coding: utf-8 -*- * * 1701.cc: No.1701 half price - yukicoder */ #include<cstdio> using namespace std; /* constant */ const int MAX_N = 13; const int NBITS = 1 << MAX_N; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int n, w; scanf("%d%d", &n, &w); for (int i = 0; i < n; i++) scanf("%d", as + i); int nbits = 1 << n, cnt = 0; for (int bits = 0; bits < nbits; bits++) { ll sum = 0; for (int i = 0, bi = 1; i < n; i++, bi <<= 1) if (bits & bi) sum += as[i]; if (sum == w) cnt++; for (int i = 0, bi = 1; i < n; i++, bi <<= 1) if (bits & bi) { ll sumi = sum - as[i] / 2; if (sumi == w) cnt++; } } printf("%d\n", cnt); return 0; }