結果

問題 No.817 Coin donation
ユーザー totori_nyaatotori_nyaa
提出日時 2019-04-19 22:42:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 175,292 KB
実行使用メモリ 5,388 KB
最終ジャッジ日時 2023-10-24 06:06:39
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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;

int main(){
    int n,k;
    cin>>n>>k;
    int a,b;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back(make_pair(a,0));
        v.push_back(make_pair(b,1));
    }
    sort(v.begin(),v.end());

    int c=0;
    int t=1;
    int p=0;
    p=v[0].first;
    for(int i=1;i<v.size();i++){
        if(v[i].second==0){
            c+=(v[i].first-p)*t;
            p=v[i].first;
            if(c>=k){
                cerr<<i<<" "<<c<<" "<<t<<" "<<p<<endl;
                int ans=p-(c-k)/t;
                cout<<ans<<endl;
                return 0;
            }
            t++;
            p=v[i].first;
        }
        else {
            c+=(v[i].first-p+1)*t;
            p=v[i].first;
            if(c>=k){
                cerr<<i<<" "<<c<<" "<<t<<" "<<p<<endl;
                int ans=p-(c-k)/t;
                cout<<ans<<endl;
                return 0;
            }
            t--;
            p=v[i].first+1;
        }
        
        cerr<<i<<" "<<c<<" "<<t<<" "<<p<<endl;
    }


    
}
0