結果
問題 | No.817 Coin donation |
ユーザー | ngtkana |
提出日時 | 2020-03-30 21:41:04 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 707 bytes |
コンパイル時間 | 2,831 ms |
コンパイル使用メモリ | 206,000 KB |
実行使用メモリ | 8,844 KB |
最終ジャッジ日時 | 2023-09-05 07:55:31 |
合計ジャッジ時間 | 4,878 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 3 ms
4,376 KB |
testcase_06 | AC | 7 ms
4,380 KB |
testcase_07 | AC | 9 ms
4,376 KB |
testcase_08 | AC | 34 ms
7,964 KB |
testcase_09 | AC | 11 ms
4,376 KB |
testcase_10 | AC | 47 ms
8,844 KB |
testcase_11 | AC | 47 ms
7,452 KB |
testcase_12 | AC | 47 ms
8,060 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
ソースコード
#include<bits/stdc++.h> using lint=long long; using real=long double; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n,k;std::cin>>n>>k;k--; std::vector<std::pair<lint,lint>>a; while(n--){ lint x,y;std::cin>>x>>y; a.emplace_back(x,+1); a.emplace_back(y+1,-1); } std::sort(a.begin(),a.end()); n=a.size(); for(lint i=0,m=0,cum=0;i<n-1;i++){ m+=a.at(i).second; lint aug=m*(a.at(i+1).first-a.at(i).first); if(k<=cum+aug){ std::cout<<a.at(i).first+(k-cum)/m<<'\n'; return 0; } cum+=aug; } }