結果
| 問題 |
No.448 ゆきこーだーの雨と雪 (3)
|
| ユーザー |
|
| 提出日時 | 2019-10-18 04:16:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 351 ms / 2,000 ms |
| コード長 | 613 bytes |
| コンパイル時間 | 654 ms |
| コンパイル使用メモリ | 71,416 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 14:00:47 |
| 合計ジャッジ時間 | 8,921 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
コンパイルメッセージ
main.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
29 | main()
| ^~~~
ソースコード
#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;
}