結果

問題 No.54 Happy Hallowe'en
ユーザー milanis48663220milanis48663220
提出日時 2020-06-24 23:50:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 574 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 89,416 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 21:27:53
合計ジャッジ時間 4,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 72 ms
4,380 KB
testcase_05 AC 117 ms
4,376 KB
testcase_06 AC 183 ms
4,380 KB
testcase_07 AC 307 ms
4,376 KB
testcase_08 AC 426 ms
4,376 KB
testcase_09 AC 574 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 414 ms
4,380 KB
testcase_13 AC 572 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int v_[10000], t_[10000];
int v[10000], t[10000];
P p[10000];
int ans;
bool ok[10001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin  >> v_[i] >> t_[i];
        p[i] = P(v_[i]+t_[i], i);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        int idx = p[i].second;
        v[i] = v_[idx];
        t[i] = t_[idx];
    }
    ok[0] = true;
    for(int i = 0; i < N; i++){
        vector<int> u;
        for(int j = 0; j <= 10000; j++){
            if(ok[j]){
                u.push_back(j);
                if(j < t[i]) u.push_back(j+v[i]);
            }
        }
        for(int j : u) {
            ok[j] = true;
            ans = max(ans, j);
        }
    }
    cout << ans << endl;
}
0