結果

問題 No.9 モンスターのレベル上げ
ユーザー penqenpenqen
提出日時 2021-03-29 02:11:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 366 ms / 5,000 ms
コード長 1,041 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 65,988 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 16:00:25
合計ジャッジ時間 4,501 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 366 ms
4,376 KB
testcase_03 AC 283 ms
4,376 KB
testcase_04 AC 151 ms
4,376 KB
testcase_05 AC 98 ms
4,376 KB
testcase_06 AC 34 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 44 ms
4,376 KB
testcase_09 AC 360 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 293 ms
4,376 KB
testcase_12 AC 226 ms
4,376 KB
testcase_13 AC 139 ms
4,380 KB
testcase_14 AC 361 ms
4,376 KB
testcase_15 AC 325 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 209 ms
4,376 KB
testcase_18 AC 173 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <climits>
#include <iostream>
#include <queue>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T MAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T MIN(T & a, const T b) { return a = (a > b) ? b : a; }

int main()
{
  INIT;
  int n; cin >> n;
  int an[n], bn[n];
  int ans = INT_MAX;
  priority_queue< int, vector<int>, greater<int> > q;
  REP(i, n) { cin >> an[i]; an[i] = an[i] << 12; }
  REP(i, n) { cin >> bn[i]; bn[i] = (bn[i] / 2) << 12; }

  REP(p, n) {
    int times = 0;
    REP(i, n) { q.push(an[i]); }
    FOR(i, p, n) { int a = q.top() + bn[i] + 1; q.pop(); q.push(a); }
    FOR(i, 0, p) { int a = q.top() + bn[i] + 1; q.pop(); q.push(a); }
    while(!q.empty()) {
      times = MAX<int>(times, q.top() & 0xFFF);
      q.pop();
    }
    ans = MIN<int>(times, ans);
  }

  cout << ans << "\n";
  return 0;
}
0