結果

問題 No.817 Coin donation
ユーザー furafura
提出日時 2020-05-24 00:47:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 2,363 ms
コンパイル使用メモリ 201,584 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 20:07:07
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 AC 12 ms
5,376 KB
testcase_08 AC 45 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 65 ms
5,856 KB
testcase_11 AC 66 ms
5,980 KB
testcase_12 AC 65 ms
6,108 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> l(n),r(n);
	rep(i,n) scanf("%d%d",&l[i],&r[i]), r[i]++;

	vector<int> X;
	rep(i,n){
		X.emplace_back(l[i]);
		X.emplace_back(r[i]);
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	int m=X.size();
	vector<int> sum(m+1);
	rep(i,n){
		sum[lower_bound(X.begin(),X.end(),l[i])-X.begin()]++;
		sum[lower_bound(X.begin(),X.end(),r[i])-X.begin()]--;
	}
	rep(i,m) sum[i+1]+=sum[i];

	rep(i,m-1){
		lint width=X[i+1]-X[i];
		if(k<=sum[i]*width){
			printf("%d\n",X[i]+k/sum[i]);
			break;
		}
		k-=sum[i]*width;
	}

	return 0;
}
0