結果

問題 No.412 花火大会
ユーザー koba-e964koba-e964
提出日時 2017-02-27 17:14:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,643 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 97,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 12:59:31
合計ジャッジ時間 2,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  VI r(3);
  int n;
  REP(i, 0, 3) { cin >> r[i]; }
  cin >> n;
  VI e(n);
  REP(i, 0, n) {
    cin >> e[i];
  }
  sort(r.rbegin(), r.rend());
  sort(e.begin(), e.end());
  VI t(3);
  REP(i, 0, 3) {
    t[i] = lower_bound(e.begin(), e.end(), r[i]) - e.begin();
  }
  // t[0] >= t[1] >= t[2]
  VL ans(8);
  REP(bits, 0, 8) {
    int sum;
    int hwid = (bits & 1) ? t[0] : n;
    // ugly hard coding :-(
    int cs = bits >> 1;
    if (cs == 0) {
      sum = 1LL << hwid;
    } else if (cs == 1) {
      sum = (1LL << t[1]) * (hwid - t[1] + 1);
    } else if (cs == 2) {
      int r = hwid - t[2];
      sum = (1LL << t[2]) * (r * (r + 1) / 2 + 1);
    } else {
      assert (cs == 3);
      int r = hwid - t[1];
      int w = t[1] - t[2];
      sum = (1LL << t[2]) * (r * (w + 1) + w * (w + 1) / 2 + 1);
    }
    ans[bits] = sum;
  }
  for (int bits = 7; bits >= 0; --bits) {
    REP(b2, bits + 1, 8) {
      if ((bits & b2) == bits) {
	ans[bits] -= ans[b2];
      }
    }
  }
  cout << ans[0] << endl;
}
0