結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-09 00:43:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 775 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 32,000 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:29:36 |
合計ジャッジ時間 | 992 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 3 ms
6,944 KB |
ソースコード
/* -*- 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; }