답안 #207985

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207985 2020-03-09T16:00:29 Z coldEr66 Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
136 ms 132324 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RREP(i,n) for (ll i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=205,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll dp[MAXn][MAXn][MAXn][2];
ll x[MAXn],T[MAXn];
int main(){
    IOS();
    ll n,L;
    cin >> n >> L;
    x[0] = 0, x[n+1] = L;
    T[0] = T[n+1] = -1;
    REP1 (i,n) cin >> x[i];
    REP1 (i,n) cin >> T[i];

    REP (i,n+2) REP (j,n+2) REP (k,n+2) REP (l,2) dp[i][j][k][l] = INF;
    dp[n+1][0][0][0] = 0;
    ll ans = 0;
    REP (len,n+1) {
        REP (j,n+1) {
            ll i = (j - len + n+1);
            if (i > n+1) continue;
            REP (k,n+1) {
                if (dp[i][j][k][0] != INF || dp[i][j][k][1] != INF) {
                    ans = max(ans,k);
                }
                if (j + 1 == i) continue;
                ll tmp;
                if (dp[i][j][k][0] != INF) {
                    debug(i,j,k);
                    ans = max(ans,k);
                    if (i > 0) {
                        tmp = dp[i][j][k][0] + x[j] + L - x[i-1];
                        dp[i-1][j][k+(tmp<=T[i-1])][1] = min(dp[i-1][j][k+(tmp<=T[i-1])][1],tmp);
                    }
                    if (j <= n) {
                        tmp = dp[i][j][k][0] + x[j+1] - x[j];
                        dp[i][j+1][k+(tmp<=T[j+1])][0] = min(dp[i][j+1][k+(tmp<=T[j+1])][0],tmp);
                    }
                }
                if (dp[i][j][k][1] != INF) {
                    debug(i,j,k);
                    ans = max(ans,k);
                    if (i > 0) {
                        tmp = dp[i][j][k][1] + x[i] - x[i-1];
                        dp[i-1][j][k+(tmp<=T[i-1])][1] = min(dp[i-1][j][k+(tmp<=T[i-1])][1],tmp);
                    }
                    if (j <= n) {
                        tmp = dp[i][j][k][1] + x[j+1] + L - x[i];
                        dp[i][j+1][k+(tmp<=T[j+1])][0] = min(dp[i][j+1][k+(tmp<=T[j+1])][0],tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 6 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 6 ms 1020 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 888 KB Output is correct
20 Correct 5 ms 1020 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1020 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1144 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 760 KB Output is correct
29 Correct 5 ms 1272 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1144 KB Output is correct
32 Correct 5 ms 1144 KB Output is correct
33 Correct 5 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 6 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 6 ms 1020 KB Output is correct
18 Correct 80 ms 106104 KB Output is correct
19 Correct 49 ms 64588 KB Output is correct
20 Correct 26 ms 34680 KB Output is correct
21 Correct 43 ms 61048 KB Output is correct
22 Correct 57 ms 78968 KB Output is correct
23 Correct 24 ms 29688 KB Output is correct
24 Correct 17 ms 23160 KB Output is correct
25 Correct 24 ms 28920 KB Output is correct
26 Correct 10 ms 11256 KB Output is correct
27 Correct 23 ms 30200 KB Output is correct
28 Correct 15 ms 21624 KB Output is correct
29 Correct 24 ms 30840 KB Output is correct
30 Correct 18 ms 24312 KB Output is correct
31 Correct 23 ms 28924 KB Output is correct
32 Correct 13 ms 15352 KB Output is correct
33 Correct 22 ms 28920 KB Output is correct
34 Correct 10 ms 10488 KB Output is correct
35 Correct 20 ms 28408 KB Output is correct
36 Correct 11 ms 13688 KB Output is correct
37 Correct 20 ms 30200 KB Output is correct
38 Correct 13 ms 16760 KB Output is correct
39 Correct 21 ms 31480 KB Output is correct
40 Correct 14 ms 18552 KB Output is correct
41 Correct 108 ms 130808 KB Output is correct
42 Correct 52 ms 88312 KB Output is correct
43 Correct 107 ms 130808 KB Output is correct
44 Correct 50 ms 87288 KB Output is correct
45 Correct 111 ms 130808 KB Output is correct
46 Correct 50 ms 88312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 764 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 1016 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 636 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 6 ms 1020 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 888 KB Output is correct
20 Correct 5 ms 1020 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1020 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1144 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 760 KB Output is correct
29 Correct 5 ms 1272 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1144 KB Output is correct
32 Correct 5 ms 1144 KB Output is correct
33 Correct 5 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 6 ms 1272 KB Output is correct
36 Correct 80 ms 106104 KB Output is correct
37 Correct 49 ms 64588 KB Output is correct
38 Correct 26 ms 34680 KB Output is correct
39 Correct 43 ms 61048 KB Output is correct
40 Correct 57 ms 78968 KB Output is correct
41 Correct 24 ms 29688 KB Output is correct
42 Correct 17 ms 23160 KB Output is correct
43 Correct 24 ms 28920 KB Output is correct
44 Correct 10 ms 11256 KB Output is correct
45 Correct 23 ms 30200 KB Output is correct
46 Correct 15 ms 21624 KB Output is correct
47 Correct 24 ms 30840 KB Output is correct
48 Correct 18 ms 24312 KB Output is correct
49 Correct 23 ms 28924 KB Output is correct
50 Correct 13 ms 15352 KB Output is correct
51 Correct 22 ms 28920 KB Output is correct
52 Correct 10 ms 10488 KB Output is correct
53 Correct 20 ms 28408 KB Output is correct
54 Correct 11 ms 13688 KB Output is correct
55 Correct 20 ms 30200 KB Output is correct
56 Correct 13 ms 16760 KB Output is correct
57 Correct 21 ms 31480 KB Output is correct
58 Correct 14 ms 18552 KB Output is correct
59 Correct 108 ms 130808 KB Output is correct
60 Correct 52 ms 88312 KB Output is correct
61 Correct 107 ms 130808 KB Output is correct
62 Correct 50 ms 87288 KB Output is correct
63 Correct 111 ms 130808 KB Output is correct
64 Correct 50 ms 88312 KB Output is correct
65 Correct 98 ms 118136 KB Output is correct
66 Correct 86 ms 108536 KB Output is correct
67 Correct 79 ms 103928 KB Output is correct
68 Correct 71 ms 95864 KB Output is correct
69 Correct 93 ms 116984 KB Output is correct
70 Correct 95 ms 112132 KB Output is correct
71 Correct 83 ms 113276 KB Output is correct
72 Correct 100 ms 114424 KB Output is correct
73 Correct 75 ms 106104 KB Output is correct
74 Correct 82 ms 99192 KB Output is correct
75 Correct 82 ms 109688 KB Output is correct
76 Correct 104 ms 125688 KB Output is correct
77 Correct 99 ms 125688 KB Output is correct
78 Correct 75 ms 97144 KB Output is correct
79 Correct 79 ms 100344 KB Output is correct
80 Correct 101 ms 123128 KB Output is correct
81 Correct 76 ms 101496 KB Output is correct
82 Correct 74 ms 107256 KB Output is correct
83 Correct 104 ms 130940 KB Output is correct
84 Correct 79 ms 112132 KB Output is correct
85 Correct 86 ms 121848 KB Output is correct
86 Correct 83 ms 119436 KB Output is correct
87 Correct 88 ms 109688 KB Output is correct
88 Correct 136 ms 132064 KB Output is correct
89 Correct 111 ms 132088 KB Output is correct
90 Correct 63 ms 110916 KB Output is correct
91 Correct 120 ms 132088 KB Output is correct
92 Correct 110 ms 132324 KB Output is correct
93 Correct 77 ms 129528 KB Output is correct