結果
問題 | No.817 Coin donation |
ユーザー |
![]() |
提出日時 | 2020-06-23 09:21:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 146 ms / 2,000 ms |
コード長 | 846 bytes |
コンパイル時間 | 1,583 ms |
コンパイル使用メモリ | 173,704 KB |
実行使用メモリ | 16,000 KB |
最終ジャッジ日時 | 2024-07-03 19:09:45 |
合計ジャッジ時間 | 3,289 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n, k; cin >> n >> k; map<ll, ll> mp; rep(i, n){ ll a, b; cin >> a >> b; b++; if(mp.count(a) == 0) mp[a] = 0; mp[a]++; if(mp.count(b) == 0) mp[b] = 0; mp[b]--; } ll sm = 0; ll t = 0; ll x = 0; for(auto p : mp){ ll y = p.first; ll z = p.second; if(sm + (y - x - 1) * t >= k){ cout << x + (k - sm + t - 1) / t << endl; exit(0); } sm += (y - x - 1) * t; if(sm + (t + z) >= k){ cout << y << endl; exit(0); } sm += t + z; x = y; t += z; } }