結果

問題 No.914 Omiyage
ユーザー ningenMeningenMe
提出日時 2019-10-22 23:31:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 170,364 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 11:46:32
合計ジャッジ時間 3,420 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	//入力
	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;
	for(int n = 0; n <= 100000; ++n) {
		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;
	}

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