結果
問題 | No.817 Coin donation |
ユーザー |
|
提出日時 | 2019-04-19 21:41:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 1,854 ms |
コンパイル使用メモリ | 174,828 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 17:50:42 |
合計ジャッジ時間 | 2,866 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
#include"bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<< #str << " " str<<endl constexpr int INF = (1 << 30); constexpr ll INFL = (1ll << 60); constexpr ll MOD = 1000000007;// 10^9+7 int main() { ll N, K; cin >> N >> K; vector<pair<ll, ll>> abs(N); REP(i, N) { ll a, b; cin >> a >> b; abs[i] = { a,b }; } sort(abs.begin(), abs.end()); ll l = 0, r = 1e9 + 10; while (r - l > 1) { ll mid = (l + r) / 2; ll num = 0; for (auto ab : abs) { ll a = ab.first; ll b = ab.second; if (mid < a)continue; if (b < mid) { num += (b - a + 1); } else { num += (mid - a + 1); } } if (num < K)l = mid; else r = mid; } cout << r << endl; return 0; }