結果
問題 | No.448 ゆきこーだーの雨と雪 (3) |
ユーザー | しらっ亭 |
提出日時 | 2016-11-19 00:15:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,948 bytes |
コンパイル時間 | 1,628 ms |
コンパイル使用メモリ | 175,256 KB |
実行使用メモリ | 18,012 KB |
最終ジャッジ日時 | 2024-05-04 19:16:32 |
合計ジャッジ時間 | 5,233 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 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 | 1 ms
5,376 KB |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | AC | 18 ms
5,376 KB |
testcase_14 | AC | 20 ms
5,632 KB |
testcase_15 | AC | 53 ms
10,112 KB |
testcase_16 | WA | - |
testcase_17 | AC | 95 ms
15,976 KB |
testcase_18 | AC | 15 ms
5,376 KB |
testcase_19 | WA | - |
testcase_20 | AC | 42 ms
7,424 KB |
testcase_21 | AC | 125 ms
17,248 KB |
testcase_22 | AC | 47 ms
9,600 KB |
testcase_23 | AC | 127 ms
17,272 KB |
testcase_24 | WA | - |
testcase_25 | AC | 125 ms
17,280 KB |
testcase_26 | WA | - |
testcase_27 | AC | 91 ms
15,852 KB |
testcase_28 | WA | - |
testcase_29 | AC | 49 ms
9,728 KB |
testcase_30 | WA | - |
testcase_31 | AC | 18 ms
5,376 KB |
testcase_32 | AC | 19 ms
5,504 KB |
testcase_33 | WA | - |
testcase_34 | AC | 133 ms
17,760 KB |
testcase_35 | WA | - |
testcase_36 | AC | 123 ms
17,876 KB |
testcase_37 | WA | - |
testcase_38 | AC | 141 ms
17,920 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__) #define _rrep2(i,n) _rrep3(i,0,n) #define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long;using pii=pair<int,int>;using vb=vector<bool>; using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>; using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>; using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>; using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>; template <typename T> T read() {T t; cin >> t; return t;} template<class V> struct SegTreeSum { const int n; vector<V> val; SegTreeSum(int _n): n(p2(_n)), val(n * 2, def) {} void reinit() { val.fill(def); } V getval(int a, int b) { return getval(a, b, 0, 0, n); } void update(int i, V v) { i += n - 1; val[i] = v; while (i > 0) { i = (i - 1) / 2; val[i] = comp(val[i * 2 + 1], val[i * 2 + 2]); } } private: V getval(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; if (a <= l && r <= b) return val[k]; return comp(getval(a, b, k * 2 + 1, l, (l + r) / 2), getval(a, b, k * 2 + 2, (l + r) / 2, r)); } static int p2(int n, int m=1) { return m >= n ? m : p2(n, m * 2); } V comp(const V &l, const V &r) { return l + r;}; const V def = 0; }; template<class V> struct SegTree0 { const int n; vector<V> val; SegTree0(int _n): n(p2(_n)), val(n * 2, def) {} void reinit() { val.fill(def); } V getval(int a, int b) { return getval(a, b, 0, 0, n); } void update(int i, V v) { i += n - 1; val[i] = v; while (i > 0) { i = (i - 1) / 2; val[i] = comp(val[i * 2 + 1], val[i * 2 + 2]); } } private: V getval(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; if (a <= l && r <= b) return val[k]; return comp(getval(a, b, k * 2 + 1, l, (l + r) / 2), getval(a, b, k * 2 + 2, (l + r) / 2, r)); } static int p2(int n, int m=1) { return m >= n ? m : p2(n, m * 2); } V comp(const V& l, const V& r) { return max(l, r);}; const V def = 0; }; template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } void Main() { int n = read<ll>(); ll k = read<ll>(); vl T(n); vl D(n); SegTree0<ll> seg(n); SegTreeSum<ll> segsum(n); rep(i, n) { T[i] = read<ll>(); D[i] = read<ll>(); seg.update(i, D[i]); segsum.update(i, D[i]); } //vector<ll> R(sz(D)+1); //rep(ii, sz(D)) R[ii+1] = R[ii] + D[ii]; const ll inf = 1e18+7; vector<pair<ll, ll>> dp(n+1); rep(i, n+1) dp[i].fst = dp[i].snd = inf; dp[0] = {0, 0}; //cout << "D:"; rep(ii,sz(D)) cout << ' ' << D[ii]; cout << endl; //cout << "R:"; rep(ii,sz(R)) cout << ' ' << R[ii]; cout << endl; rep(i, n) { //_p("dp[%d]: (%lld, %lld)\n", i, dp[i].fst, dp[i].snd); ll t = T[i]; ll d = D[i]; // yaru amin(dp[i + 1], {max(dp[i].fst, d), dp[i].snd + d}); // yaraseru int ni = distance(T.begin(), lower_bound(all(T), t + k)); //ll su = R[ni - 1 + 1] - R[i + 1]; ll su = segsum.getval(i + 1, ni); ll ma = seg.getval(i + 1, ni); //cout<<"ni: "<<ni<<endl; //cout<<"su: "<<su<<endl; //cout<<"ma: "<<ma<<endl; amin(dp[ni], {max(dp[i].fst, ma), dp[i].snd + su}); } _p("%lld\n%lld\n", dp[n].fst, dp[n].snd); //cout << dp[n].fst << endl << dp[n].snd << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }