結果

問題 No.1715 Dinner 2
ユーザー _san_yo_san_yo
提出日時 2021-10-22 23:24:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 170,896 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 15:29:16
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 3 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:53:9: warning: 'f' may be used uninitialized [-Wmaybe-uninitialized]
   53 |         if(!f){
      |         ^~
main.cpp:22:10: note: 'f' was declared here
   22 |     bool f;
      |          ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

typedef struct{
    ll p;
    ll q;
    ll num;
} CELL;

int cmp(CELL a, CELL b){
    if(a.q - a.p > b.q - b.p){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    ll n,d,t,l = -1000000000,r = 0,m,tm;
    CELL c[1000] = {};
    bool f;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        cin >> c[i].p >> c[i].q;
        c[i].num = i;
    }
    sort(c,c+n,cmp);
    while(l < r){
        m = (l+r)/2;
        tm = 0;
        t = -1;
        for(int i = 0; i < d; i++){
            f = true;
            for(int j = 0; j < n; j++){
                if(tm >= m + c[j].p && t != j){
                    t = j;
                    tm += c[j].q - c[j].p;
                    f = false;
                    break;
                }
            }
            if(f){
                if(r == m){
                    cout << l;
                    return 0;
                }else{
                    r = m;
                }
                break;
            }
        }
        if(!f){
            if(r == m){
                cout << r;
                return 0;
            }else{
                l = m;
            }
        }
    }
}
0