結果
問題 | No.448 ゆきこーだーの雨と雪 (3) |
ユーザー | imulan |
提出日時 | 2016-11-19 03:13:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,857 bytes |
コンパイル時間 | 1,946 ms |
コンパイル使用メモリ | 171,604 KB |
実行使用メモリ | 7,308 KB |
最終ジャッジ日時 | 2024-05-04 20:42:13 |
合計ジャッジ時間 | 3,836 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second int dp[200001]={0}; int main() { int n,k; scanf(" %d %d", &n, &k); vector<int> t(n), d(n); int D=0; rep(i,n) { scanf(" %d %d", &t[i], &d[i]); D=max(D,d[i]); } int l=-1, r=D; while(r-l>1) { int m=(l+r)/2; bool ok=true; int b=-k; rep(i,n) { if(d[i]>m) { if(t[i]-b<k) { ok=false; break; } b=t[i]; } } if(ok) r=m; else l=m; } vector<bool> yuki(n,true); int b=-k; rep(i,n) { if(d[i]>r) { b=t[i]; yuki[i]=false; } else { if(t[i]-b<k) yuki[i]=false; } } b=2000000001; for(int i=n-1; i>=0; --i) { if(d[i]>r) { b=t[i]; yuki[i]=false; } else { if(b-t[i]<k) yuki[i]=false; } } vector<int> yt,yd; rep(i,n) { if(yuki[i]) { yt.pb(t[i]); yd.pb(d[i]); } } int Y=yt.size(); int lidx=0; rep(i,Y) { while(i>lidx) { if(yt[i]-yt[lidx]<k) break; ++lidx; } dp[i+1] = max(dp[i],dp[lidx]+yd[i]); } int sum=0; int yuki_sum=dp[Y]; rep(i,n) { sum+=d[i]; if(d[i]>r) yuki_sum+=d[i]; } printf("%d\n%d\n",r,sum-yuki_sum); return 0; }