結果

問題 No.9 モンスターのレベル上げ
ユーザー y_mazuny_mazun
提出日時 2015-04-17 02:58:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 446 ms / 5,000 ms
コード長 797 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 50,772 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 03:44:07
合計ジャッジ時間 5,194 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 446 ms
4,380 KB
testcase_03 AC 360 ms
4,376 KB
testcase_04 AC 185 ms
4,376 KB
testcase_05 AC 121 ms
4,380 KB
testcase_06 AC 41 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
4,384 KB
testcase_09 AC 439 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 369 ms
4,376 KB
testcase_12 AC 299 ms
4,380 KB
testcase_13 AC 218 ms
4,380 KB
testcase_14 AC 444 ms
4,380 KB
testcase_15 AC 400 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 256 ms
4,376 KB
testcase_18 AC 212 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  vector<int> a(n);
  vector<int> b(n);

  REP(i,n) a[i] = getInt();
  REP(i,n) b[i] = getInt();

  int ans = n;
  REP(s,n){
    typedef pair<int, int> data;
    priority_queue<data, vector<data>, greater<data> > pq;
    REP(i,n) pq.push(make_pair(a[i], 0));

    REP(i,n){
      const data d = pq.top(); pq.pop();
      const int bb = b[(i + s) % n];
      pq.push(data(d.first + bb / 2, d.second + 1));
    }

    int tmp = 0;
    while(pq.size()){
      tmp = max(tmp, pq.top().second);
      pq.pop();
    }

    ans = min(ans, tmp);
  }

  printf("%d\n", ans);
  return 0;
}
0