結果

問題 No.9 モンスターのレベル上げ
ユーザー hogeover30hogeover30
提出日時 2015-02-12 20:45:58
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 762 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 57,468 KB
最終ジャッジ日時 2023-09-06 03:37:22
合計ジャッジ時間 766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:9: error: ‘vector’ was not declared in this scope
         vector<int> b(n);
         ^~~~~~
main.cpp:9:9: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:4:1:
+#include <vector>
 using namespace std;
main.cpp:9:9:
         vector<int> b(n);
         ^~~~~~
main.cpp:9:16: error: expected primary-expression before ‘int’
         vector<int> b(n);
                ^~~
main.cpp:15:21: error: ‘b’ was not declared in this scope
         for(int& v: b) cin>>v;
                     ^
main.cpp:24:26: error: ‘b’ was not declared in this scope
                 x.first+=b[(i+k)%n]/2;
                          ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
    int n;
    while (cin>>n) {
        vector<int> b(n);
        multiset<pair<int, int>> a;
        for(int i=0;i<n;++i) {
            int t; cin>>t;
            a.emplace(t, 0);
        }
        for(int& v: b) cin>>v;

        int res=1000000;
        for(int k=0;k<n;++k) {
            auto s=a;
            int cnt=0;
            for(int i=0;i<n;++i) {
                auto t=s.begin();
                auto x=*t;
                x.first+=b[(i+k)%n]/2;
                x.second++;
                cnt=max(cnt, x.second);
                s.erase(t);
                s.insert(x);
            }
            res=min(res, cnt);
        }
        cout<<res<<endl;
    }
}
0