結果

問題 No.1715 Dinner 2
ユーザー hiikunZhiikunZ
提出日時 2022-05-15 15:18:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,241 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 208,400 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-09 23:47:49
合計ジャッジ時間 5,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
mt19937 mt;
void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}
int main(){
    ll N,D;
    cin >> N >> D;
    vector<ll> P(N),Q(N);
    for(ll i = 0;i < N;i++) cin >> P[i] >> Q[i];
    vector<tuple<ll,ll>> H(N);
    for(ll i = 0;i < N;i++) H[i] = make_tuple(-P[i] + Q[i],P[i]);
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    ll l = -MAX,r = 1;
    while(r - l > 1){
        ll m = (l + r) / 2,n = 0,ok = 1;
        for(ll i = 0;i < D;i++){
            ll o = 0;
            for(ll j = 0;j < N;j++){
                if(n - get<1>(H[i]) >= m){
                    n += get<0>(H[i]);
                    o = 1;
                    break;
                }
            }
            if(!o){
                ok = 0;
                break;
            }
        }
        if(ok) l = m;
        else r = m;
    }
    cout << l << endl;
}
0