結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー kotatsugamekotatsugame
提出日時 2019-10-18 04:16:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 70,864 KB
実行使用メモリ 6,688 KB
最終ジャッジ日時 2023-09-07 20:14:45
合計ジャッジ時間 9,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 43 ms
4,376 KB
testcase_14 AC 46 ms
4,384 KB
testcase_15 AC 116 ms
4,600 KB
testcase_16 AC 204 ms
5,384 KB
testcase_17 AC 167 ms
5,548 KB
testcase_18 AC 34 ms
4,376 KB
testcase_19 AC 281 ms
6,200 KB
testcase_20 AC 87 ms
4,376 KB
testcase_21 AC 258 ms
6,168 KB
testcase_22 AC 95 ms
4,516 KB
testcase_23 AC 283 ms
6,344 KB
testcase_24 AC 67 ms
4,380 KB
testcase_25 AC 262 ms
6,248 KB
testcase_26 AC 32 ms
4,376 KB
testcase_27 AC 218 ms
5,468 KB
testcase_28 AC 195 ms
5,364 KB
testcase_29 AC 110 ms
4,504 KB
testcase_30 AC 295 ms
6,356 KB
testcase_31 AC 37 ms
4,380 KB
testcase_32 AC 35 ms
4,380 KB
testcase_33 AC 323 ms
6,496 KB
testcase_34 AC 263 ms
6,688 KB
testcase_35 AC 324 ms
6,540 KB
testcase_36 AC 218 ms
6,608 KB
testcase_37 AC 309 ms
6,452 KB
testcase_38 AC 319 ms
6,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:29:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   29 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,K;
int T[2<<17],D[2<<17];
long f(int X)
{
	vector<long>dp(N+1,2e18);
	dp[0]=0;
	int id=0;
	long ns=0;
	int cnt=0;
	for(int i=0;i<N;i++)
	{
		if(D[i]<=X)dp[i+1]=dp[i]+D[i];
		while(T[id]+K<=T[i])
		{
			ns-=D[id];
			cnt-=D[id]>X;
			id++;
		}
		if(cnt==0)dp[i+1]=min(dp[i+1],dp[id]+ns);
		ns+=D[i];
		if(D[i]>X)cnt++;
	}
	return dp[N];
}
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>T[i]>>D[i];
	int L=-1,R=1e9;
	while(R-L>1)
	{
		int M=(L+R)/2;
		long now=f(M);
		if(f(M)<1e18)R=M;
		else L=M;
	}
	cout<<R<<endl<<f(R)<<endl;
}
0