結果
| 問題 |
No.914 Omiyage
|
| ユーザー |
|
| 提出日時 | 2019-10-25 19:56:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 857 bytes |
| コンパイル時間 | 1,796 ms |
| コンパイル使用メモリ | 173,588 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-21 19:59:34 |
| 合計ジャッジ時間 | 46,467 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 4 |
ソースコード
#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>1980.) break;
}
if(ans==K) ans = -1;
cout << ans << endl;
return 0;
}