結果

問題 No.1460 Max of Min
ユーザー SSRSSSRS
提出日時 2021-03-31 21:52:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 535 ms / 2,000 ms
コード長 1,207 bytes
コンパイル時間 1,760 ms
コンパイル使用メモリ 173,964 KB
実行使用メモリ 11,332 KB
最終ジャッジ日時 2023-08-22 01:17:43
合計ジャッジ時間 34,172 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 480 ms
10,972 KB
testcase_04 AC 493 ms
11,156 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 473 ms
11,168 KB
testcase_07 AC 478 ms
11,168 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 475 ms
10,960 KB
testcase_11 AC 464 ms
11,032 KB
testcase_12 AC 85 ms
4,704 KB
testcase_13 AC 425 ms
10,216 KB
testcase_14 AC 130 ms
5,692 KB
testcase_15 AC 58 ms
4,380 KB
testcase_16 AC 390 ms
10,252 KB
testcase_17 AC 219 ms
7,096 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 187 ms
6,448 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 24 ms
4,380 KB
testcase_22 AC 193 ms
6,708 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 251 ms
8,076 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 457 ms
10,752 KB
testcase_27 AC 62 ms
4,380 KB
testcase_28 AC 17 ms
4,380 KB
testcase_29 AC 233 ms
7,444 KB
testcase_30 AC 433 ms
10,172 KB
testcase_31 AC 202 ms
6,832 KB
testcase_32 AC 366 ms
9,424 KB
testcase_33 AC 111 ms
5,112 KB
testcase_34 AC 165 ms
6,244 KB
testcase_35 AC 57 ms
4,380 KB
testcase_36 AC 21 ms
4,376 KB
testcase_37 AC 227 ms
7,336 KB
testcase_38 AC 389 ms
9,760 KB
testcase_39 AC 123 ms
5,504 KB
testcase_40 AC 82 ms
4,636 KB
testcase_41 AC 57 ms
4,384 KB
testcase_42 AC 34 ms
4,380 KB
testcase_43 AC 192 ms
6,820 KB
testcase_44 AC 329 ms
9,268 KB
testcase_45 AC 9 ms
4,376 KB
testcase_46 AC 143 ms
5,896 KB
testcase_47 AC 190 ms
6,676 KB
testcase_48 AC 375 ms
9,756 KB
testcase_49 AC 267 ms
7,832 KB
testcase_50 AC 14 ms
4,380 KB
testcase_51 AC 213 ms
7,108 KB
testcase_52 AC 47 ms
4,376 KB
testcase_53 AC 235 ms
7,440 KB
testcase_54 AC 497 ms
11,108 KB
testcase_55 AC 478 ms
11,160 KB
testcase_56 AC 468 ms
11,092 KB
testcase_57 AC 535 ms
10,964 KB
testcase_58 AC 480 ms
11,024 KB
testcase_59 AC 473 ms
11,164 KB
testcase_60 AC 469 ms
11,032 KB
testcase_61 AC 472 ms
11,164 KB
testcase_62 AC 459 ms
11,044 KB
testcase_63 AC 470 ms
11,160 KB
testcase_64 AC 480 ms
11,024 KB
testcase_65 AC 455 ms
11,164 KB
testcase_66 AC 463 ms
10,964 KB
testcase_67 AC 455 ms
11,168 KB
testcase_68 AC 475 ms
10,976 KB
testcase_69 AC 457 ms
11,308 KB
testcase_70 AC 444 ms
11,152 KB
testcase_71 AC 448 ms
11,024 KB
testcase_72 AC 470 ms
11,028 KB
testcase_73 AC 482 ms
11,160 KB
testcase_74 AC 454 ms
10,900 KB
testcase_75 AC 454 ms
11,332 KB
testcase_76 AC 469 ms
10,760 KB
testcase_77 AC 456 ms
10,716 KB
testcase_78 AC 466 ms
10,956 KB
testcase_79 AC 461 ms
10,892 KB
testcase_80 AC 444 ms
10,832 KB
testcase_81 AC 443 ms
10,696 KB
testcase_82 AC 439 ms
10,880 KB
testcase_83 AC 452 ms
10,976 KB
testcase_84 AC 453 ms
10,704 KB
testcase_85 AC 447 ms
10,840 KB
testcase_86 AC 438 ms
10,760 KB
testcase_87 AC 448 ms
11,072 KB
testcase_88 AC 473 ms
10,972 KB
testcase_89 AC 471 ms
11,032 KB
testcase_90 AC 446 ms
10,752 KB
testcase_91 AC 465 ms
10,972 KB
testcase_92 AC 450 ms
11,156 KB
testcase_93 AC 435 ms
10,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
vector<long long> add1(vector<long long> x, vector<long long> d){
  int K = d.size();
  vector<long long> ans(K);
  ans[0] = min(d[0], x[K - 1]);
  for (int i = 1; i < K; i++){
    ans[i] = max(x[i - 1], min(d[i], x[K - 1]));
  }
  return ans;
}
vector<long long> mul2(vector<long long> x, vector<long long> d){
  int K = d.size();
  vector<vector<long long>> next(K);
  next[0] = x;
  for (int i = 1; i < K; i++){
    next[i] = add1(next[i - 1], d);
  }
  vector<long long> ans(K, -INF);
  for (int i = 0; i < K; i++){
    for (int j = 0; j < K; j++){
      ans[j] = max(ans[j], min(next[i][j], x[i]));
    }
  }
  return ans;
}
int main(){
  int K;
  long long N;
  cin >> K >> N;
  vector<long long> A(K);
  for (int i = 0; i < K; i++){
    cin >> A[i];
  }
  vector<long long> B(K);
  for (int i = 0; i < K; i++){
    cin >> B[i];
  }
  vector<long long> C(K, -INF);
  C[0] = INF;
  for (int i = 60; i >= 0; i--){
    C = mul2(C, B);
    if ((N >> i & 1) == 1){
      C = add1(C, B);
    }
  }
  long long ans = -INF;
  for (int i = 0; i < K; i++){
    ans = max(ans, min(A[i], C[i]));
  }
  cout << ans << endl;
}
0