結果

問題 No.1715 Dinner 2
ユーザー 沙耶花沙耶花
提出日時 2021-10-22 21:47:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,396 bytes
コンパイル時間 4,682 ms
コンパイル使用メモリ 273,532 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 12:50:23
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 4 ms
4,348 KB
testcase_26 AC 4 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 6 ms
4,348 KB
testcase_33 AC 6 ms
4,348 KB
testcase_34 AC 7 ms
4,348 KB
testcase_35 AC 7 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

pair<long long,int> op(pair<long long,int> a,pair<long long,int> b){
	return max(a,b);
}

pair<long long,int> e(){
	return make_pair(-Inf,-1);
}

int main(){
	
	int N,D;
	cin>>N>>D;
	
	vector<int> p(N),q(N);
	rep(i,N)cin>>p[i]>>q[i];
	vector<pair<long long,long long>> ps;
	rep(i,N){
		q[i] = q[i] - p[i];
		p[i] *= -1;
		ps.emplace_back(p[i],q[i]);
	}
	sort(ps.begin(),ps.end());
	vector<pair<long long,int>> t(ps.size());
	rep(i,ps.size()){
		t[i] = make_pair(ps[i].second,i);
	}
	long long ok = Inf,ng = 0LL;
	while(ok-ng>1LL){
		long long mid = (ok+ng)/2;
		
		long long cur = 0LL;
		segtree<pair<long long,int>,op,e> seg(t);
		bool f = true;
		int last = -1;
		rep(_,D){
			pair<long long,long long> temp = make_pair(-mid - cur, -1);
			int d = lower_bound(ps.begin(),ps.end(),temp) - ps.begin();//distance(ps.begin,lower_bound(ps.begin(),ps.end(),temp));
			
			auto ret = seg.prod(d,t.size());
			if(ret.second==-1){
				f = false;
				break;
			}
			
			cur += ret.first;
			
			if(last!=-1){
				seg.set(last,make_pair(ps[last].second,last));
			}
			last = ret.second;
			seg.set(last,e());
			
		}
		if(f)ok = mid;
		else ng = mid;
	}
	
	cout<<-ok<<endl;
	
	
	return 0;
}
0