結果
問題 | No.448 ゆきこーだーの雨と雪 (3) |
ユーザー | rickytheta |
提出日時 | 2016-11-18 22:48:57 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,983 bytes |
コンパイル時間 | 1,101 ms |
コンパイル使用メモリ | 144,948 KB |
実行使用メモリ | 9,672 KB |
最終ジャッジ日時 | 2023-09-02 12:49:31 |
合計ジャッジ時間 | 3,832 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,608 KB |
testcase_01 | AC | 2 ms
5,612 KB |
testcase_02 | AC | 2 ms
5,596 KB |
testcase_03 | AC | 2 ms
5,536 KB |
testcase_04 | AC | 2 ms
5,600 KB |
testcase_05 | AC | 2 ms
5,564 KB |
testcase_06 | AC | 2 ms
5,556 KB |
testcase_07 | AC | 2 ms
5,640 KB |
testcase_08 | AC | 2 ms
5,548 KB |
testcase_09 | AC | 2 ms
5,576 KB |
testcase_10 | AC | 3 ms
5,608 KB |
testcase_11 | AC | 2 ms
5,608 KB |
testcase_12 | AC | 2 ms
5,672 KB |
testcase_13 | AC | 9 ms
6,252 KB |
testcase_14 | AC | 10 ms
6,204 KB |
testcase_15 | AC | 24 ms
7,084 KB |
testcase_16 | AC | 38 ms
8,260 KB |
testcase_17 | AC | 38 ms
8,336 KB |
testcase_18 | AC | 8 ms
5,964 KB |
testcase_19 | AC | 51 ms
9,012 KB |
testcase_20 | AC | 20 ms
6,968 KB |
testcase_21 | AC | 50 ms
9,028 KB |
testcase_22 | AC | 19 ms
7,056 KB |
testcase_23 | AC | 50 ms
9,040 KB |
testcase_24 | AC | 13 ms
6,392 KB |
testcase_25 | AC | 51 ms
9,000 KB |
testcase_26 | AC | 7 ms
5,988 KB |
testcase_27 | AC | 38 ms
8,248 KB |
testcase_28 | AC | 34 ms
8,024 KB |
testcase_29 | AC | 21 ms
7,020 KB |
testcase_30 | AC | 52 ms
9,240 KB |
testcase_31 | AC | 9 ms
6,364 KB |
testcase_32 | AC | 10 ms
6,180 KB |
testcase_33 | AC | 53 ms
9,364 KB |
testcase_34 | AC | 54 ms
9,376 KB |
testcase_35 | AC | 54 ms
9,424 KB |
testcase_36 | AC | 53 ms
9,672 KB |
testcase_37 | AC | 54 ms
9,436 KB |
testcase_38 | AC | 55 ms
9,532 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define CHMIN(a,b) a=min((a),(b)) #define CHMAX(a,b) a=max((a),(b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a)%MOD+MOD)%MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x)<EPS) #define EQ(a,b) (abs(a-b)<EPS) typedef complex<Real> P; int n,k; pii qs[252521]; ll psum[252521]; int cnt[252521]; ll dp[252521]; int main(){ scanf("%d%d",&n,&k); REP(i,n){ int t,d; scanf("%d%d",&t,&d); qs[i] = pii(t,d); } // calc max difficulty int low = -1, high = 1000000025; while(low+1 < high){ int mid = (low+high)/2; int last = -k; bool flag = true; REP(i,n){ if(qs[i].second > mid){ // wake if(qs[i].first - last >= k){ // ok last = qs[i].first; }else{ // ng flag = false; break; } } } if(flag){ high = mid; }else{ low = mid; } } int mxd = high; REP(i,n)psum[i+1] = psum[i]+qs[i].second; REP(i,n)cnt[i+1] = cnt[i]+(int)(qs[i].second > mxd); REP(i,n+1)dp[i] = (ll)1e18; dp[0] = 0; int plusk = 0; REP(i,n){ int now = qs[i].first; int dif = qs[i].second; // use if(dif <= mxd)CHMIN(dp[i+1],dp[i]+dif); // skip this while(plusk < n && qs[plusk].first < now+k)plusk++; if(cnt[plusk]-cnt[i+1]==0)CHMIN(dp[plusk],dp[i]+psum[plusk]-psum[i+1]); } printf("%d\n%lld\n",mxd,dp[n]); return 0; }