結果

問題 No.817 Coin donation
ユーザー tactac
提出日時 2019-04-20 11:37:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 113,112 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-26 01:30:36
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 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 AC 1 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n, k;
    cin >> n >> k;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    int l = 1, r = 1e9 + 1;
    int cou = 0;
    while (l + 1 < r) { //break when l + 1 = r
        cou++;
        if (cou > 200) break;
        int mid = (l + r) / 2;
        //cout << l << " " << mid << " " << r << endl;
        int c = 0;
        rep(i, n) { //何枚がmid円以下か
            c += max(0, min(mid, b[i]) - a[i] + 1);
        }
        if (c >= k) { //足りてるから数字大きくする
            r = mid + 1;
        } else { //足りない
            l = mid;
        }
    }
    cout << l + 1 << endl;
}
0