結果

問題 No.914 Omiyage
ユーザー ningenMe
提出日時 2019-10-22 23:31:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 172,692 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 02:48:50
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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