結果
| 問題 |
No.412 花火大会
|
| ユーザー |
|
| 提出日時 | 2016-09-29 22:47:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,077 bytes |
| コンパイル時間 | 541 ms |
| コンパイル使用メモリ | 70,604 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 10:42:10 |
| 合計ジャッジ時間 | 1,232 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
ll p(int n) { return 1ll << n; }
ll c(int n, int r) {
ll acc = 1;
repeat (i,r) acc *= n-i;
repeat (i,r) acc /= i+1;
return acc;
}
ll f(int n, int r) {
ll acc = p(n);
repeat (i,r) acc -= c(n,i);
return acc;
}
int main() {
// input
int b, c, d; cin >> b >> c >> d;
int n; cin >> n;
vector<int> es(n); repeat (i,n) cin >> es[i];
// compute
array<int,4> e = {};
repeat (i,n) {
int cnt = 0;
cnt += int(b <= es[i]);
cnt += int(c <= es[i]);
cnt += int(d <= es[i]);
e[cnt] += 1;
}
ll ans = 0;
ans += p(e[0]) * f(e[1], 1) * f(e[2], 1) * f(e[3], 1);
ans += p(e[0]) * f(e[1], 1) * f(e[3], 2);
ans += p(e[0]) * f(e[2], 2) * f(e[3], 1);
ans += p(e[0]) * e[2] * f(e[3], 2);
ans += p(e[0]) * f(e[3], 3);
cout << ans << endl;
return 0;
}