結果
問題 | No.817 Coin donation |
ユーザー |
![]() |
提出日時 | 2019-04-19 21:42:31 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,089 bytes |
コンパイル時間 | 804 ms |
使用メモリ | 5,116 KB |
最終ジャッジ日時 | 2022-11-22 07:55:35 |
合計ジャッジ時間 | 1,935 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
3,464 KB |
testcase_01 | AC | 2 ms
3,432 KB |
testcase_02 | AC | 1 ms
3,516 KB |
testcase_03 | AC | 2 ms
3,492 KB |
testcase_04 | AC | 1 ms
3,400 KB |
testcase_05 | AC | 2 ms
3,444 KB |
testcase_06 | AC | 4 ms
3,672 KB |
testcase_07 | AC | 5 ms
3,852 KB |
testcase_08 | AC | 17 ms
4,620 KB |
testcase_09 | AC | 6 ms
3,716 KB |
testcase_10 | AC | 24 ms
5,116 KB |
testcase_11 | AC | 25 ms
5,072 KB |
testcase_12 | AC | 25 ms
5,100 KB |
testcase_13 | AC | 2 ms
3,460 KB |
testcase_14 | AC | 1 ms
3,500 KB |
testcase_15 | AC | 1 ms
3,444 KB |
ソースコード
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <random> #include <bitset> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; using namespace std; const ll MOD = 1000000007LL; ll n, k; ll A[100005], B[100005]; // 金額がiのコインはk番目未満か bool check(ll i) { ll cnt = 0; for (int j = 0; j < n; j++) { if (i >= A[j]) { if (i <= B[j]) { cnt += i - A[j] + 1; } else { cnt += B[j] - A[j] + 1; } } } if (cnt < k) { return true; } else { return false; } } int main() { cin.sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i ++) { cin >> A[i] >> B[i]; } ll l = 0, r = 1e9; while (r - l > 1) { ll mid = (l + r) / 2; if (check(mid)) { l = mid; } else { r = mid; } } cout << r << "\n"; return 0; }