結果
| 問題 | 
                            No.1701 half price
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-10-09 16:22:23 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 519 bytes | 
| コンパイル時間 | 2,334 ms | 
| コンパイル使用メモリ | 196,576 KB | 
| 最終ジャッジ日時 | 2025-01-24 23:54:18 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 WA * 4 | 
ソースコード
#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 = 0; 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;
}