結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-18 20:12:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 3,000 ms |
| コード長 | 517 bytes |
| コンパイル時間 | 2,131 ms |
| コンパイル使用メモリ | 197,468 KB |
| 最終ジャッジ日時 | 2025-01-25 01:50:15 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long n, w, nx = 1;
long long a[13];
set<long long> s;
int main()
{
cin >> n >> w;
for (long long i = 0; i < n; i++) {
cin >> a[i];
nx *= 3;
}
for (long long j = 1; j < nx; j++) {
long long x = 0, y = j, k = 0, u = 0;
while (y > 0) {
if (y % 3 == 1) {
x += a[k];
u += (1 << k);
}
else if (y % 3 == 2) {
x += a[k] / 2;
u += (1 << k);
}
y /= 3;
k++;
}
if (x == w)
s.insert(u);
}
cout << s.size() << endl;
}