結果

問題 No.817 Coin donation
ユーザー mdan16Dmdan16D
提出日時 2019-04-20 02:29:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,124 bytes
コンパイル時間 1,807 ms
コンパイル使用メモリ 172,620 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:58:14
合計ジャッジ時間 4,208 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 309 ms
4,348 KB
testcase_06 AC 221 ms
4,348 KB
testcase_07 AC 126 ms
4,348 KB
testcase_08 AC 155 ms
4,348 KB
testcase_09 AC 119 ms
4,348 KB
testcase_10 AC 191 ms
4,348 KB
testcase_11 AC 193 ms
4,348 KB
testcase_12 AC 195 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};


int main() {
    int N, K;
    vector<int> A, B;
    cin >> N >> K;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    int count = 0;
    for (ll i = 1; i <= K; i++) {
        auto iter = upper_bound(ALL(A), i);
        auto iter2 = lower_bound(ALL(B), i);
        int inc_num = iter - A.begin();
        int dec_num = iter2 - B.begin();
        
        count += inc_num - dec_num;
        if (count >= K) {
            cout << i << endl;
            return 0;
        }
    }
}
0