結果

問題 No.914 Omiyage
ユーザー ningenMeningenMe
提出日時 2019-10-25 19:57:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 171,536 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 01:22:38
合計ジャッジ時間 44,800 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	//入力
	clock_t start = clock();

	int N,M,K; cin >> N >> M >> K;

	vector<vector<int>> a(N,vector<int>(M));
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < M; ++j) {
			cin >> a[i][j];
		}
	}
	random_device rnd;     // 非決定的な乱数生成器を生成
    mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    uniform_int_distribution<> randN(1, M);        // [0, 99] 範囲の一様乱数

	int ans = K;
	while(1) {
		int sum = 0;
		for(int i = 0; i < N; ++i) {
			sum += a[i][randN(mt)-1];
		}
		if(sum<=K && ans > K - sum) ans=K-sum;

		clock_t end = clock();
		double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
		if(time>1900.) break;
	}

	if(ans==K) ans = -1; 
	cout << ans << endl;
    return 0;
}
0