結果

問題 No.155 生放送とBGM
ユーザー pazzle1230
提出日時 2019-02-07 01:47:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,644 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 171,424 KB
実行使用メモリ 21,020 KB
最終ジャッジ日時 2025-01-29 02:12:20
合計ジャッジ時間 6,056 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int64*’ {aka ‘long int*’} [-Wformat=]
   49 |                 scanf("%d:%d", &m, &s);
      |                        ~^      ~~
      |                         |      |
      |                         int*   int64* {aka long int*}
      |                        %ld
main.cpp:49:28: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int64*’ {aka ‘long int*’} [-Wformat=]
   49 |                 scanf("%d:%d", &m, &s);
      |                           ~^       ~~
      |                            |       |
      |                            int*    int64* {aka long int*}
      |                           %ld
main.cpp:49:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |                 scanf("%d:%d", &m, &s);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 N, L;
vector<int64> S;
vector<double> fact;

int64 get(const vector<vector<int64>> &v, int64 i, int64 j){
	if (i < 0 || j < 0) return 0;
	return v[i][j];
}

void init(){
	fact.resize(100, 1);
	FOR(i, 1, 100){
		fact[i] = fact[i-1] * i;
	}
}

int main(void){
	init();
	cin >> N >> L;
	L *= 60;
	S.resize(N);
	REP(i, N){
		int64 m, s;
		scanf("%d:%d", &m, &s);
		S[i] = m*60+s;
	}
	vector<vector<int64>> dp(N+1, vector<int64>(L+60*60+1, 0));
	dp[0][0] = 1;
	REP(i, N){
		vector<vector<int64>> dp2(N+1, vector<int64>(L+60*60+1, 0));
		REP(j, N+1){
			REP(k, L+60*60+1){
				dp2[j][k] = get(dp, j-1, k-S[i]) + get(dp, j, k);
			}
		}
		swap(dp, dp2);
	}
	double res = 0;
	REP(i, N){
		vector<vector<int64>> dp2(N+1, vector<int64>(L+60*60+1, 0));
		REP(j, N+1){
			REP(k, L+60*60+1){
				dp2[j][k] = dp[j][k] - get(dp2, j-1, k-S[i]);
				if (k < L && N-j-1 >= 0)
					res += dp2[j][k] * fact[j] * fact[N-j-1] / fact[N];
			}
		}
	}
	cout << fixed << setprecision(10) << res << endl;
}
0