結果

問題 No.412 花火大会
ユーザー goodbatongoodbaton
提出日時 2016-08-13 13:32:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,566 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 06:29:20
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 AC 8 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |   for(int i=0;i<3;i++) scanf("%d",b+i);
      |                        ~~~~~^~~~~~~~~~
main.cpp:63:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   63 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:64:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   64 |   for(int i=0;i<n;i++) scanf("%d",e+i);
      |                        ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

int b[3];


void calc(int *array,int size, int *result){
  
  for(int i=0;i<(1<<size);i++){
    int s[3] = {};
    
    for(int j=0;j<size;j++){
      if(!(i & (1<<j))) continue; 

      for(int k=0;k<3;k++){
        if(b[k] <= array[j]){
          s[k]++;
          break;
        }
      }
      
    }

    s[0]=min(s[0],3);
    s[1]=min(s[1],2);
    s[2]=min(s[2],1);

    result[s[0]*6 + s[1]*2 + s[2]] ++;
  }

}

int main(){
  int n,e[SIZE];
  int res1[24] = {},res2[24] = {};

  for(int i=0;i<3;i++) scanf("%d",b+i);
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",e+i);

  if(n<3){
    puts("0");
    return 0;
  }
  
  sort(b,b+3,greater<int>());
  
  calc(e,n/2,res1);
  calc(e+(n/2),n-(n/2),res2);
  
  ll ans = 0;
  
  for(int i=0;i<24;i++){
    for(int j=0;j<24;j++){
      int s[3];
      s[0] = i/6 + j/6;
      s[1] = i/2%3 + j/2%3;
      s[2] = i%2 + j%2;

      s[1] += max(s[0]-1,0);
      s[2] += max(s[1]-1,0);

      if(s[0]>0 && s[1]>0 && s[2]>0){
        ans += (ll)res1[i] * res2[j];
      }
    }
  }

  printf("%lld\n",ans);
  
  return 0;
}
0