結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
![]() |
提出日時 | 2014-11-16 03:16:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 309 ms / 5,000 ms |
コード長 | 1,043 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 46,052 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 22:04:37 |
合計ジャッジ時間 | 3,843 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:15:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | for(int i=0;i<N;i++){scanf("%d", A+i);} | ~~~~~^~~~~~~~~~~ main.cpp:16:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | for(int i=0;i<N;i++){scanf("%d", B+i);} | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <queue> #define mp std::make_pair typedef std::pair<int,int> P; typedef std::pair<P, int> State; int main(){ int N; scanf("%d", &N); int A[1500], B[1500]; for(int i=0;i<N;i++){scanf("%d", A+i);} for(int i=0;i<N;i++){scanf("%d", B+i);} int res = 1500; for(int first=0;first<N;first++){ int counter[1500]; std::fill(counter, counter+1500, 0); std::priority_queue<State, std::vector<State>, std::greater<State>> q; for(int i=0;i<N;i++){q.push(mp(mp(A[i], 0), i));} for(int i=0;i<N;i++){ State s = q.top(); q.pop(); int index = (first+i) % N; q.push(mp(mp(s.first.first+B[index]/2, s.first.second+1), s.second)); counter[s.second] += 1; } int mx = 0; for(int i=0;i<N;i++){ mx = std::max(mx, counter[i]); } res = std::min(res, mx); } printf("%d\n", res); }