답안 #682784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682784 2023-01-17T02:39:23 Z Paul_Liao_1457 Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
176 ms 258292 KB
//記得跳題
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
 
#define ll long long
#define LL __int128_t
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (ll)(2e9)
#define MOD (ll)(1e9+7)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;

template<class T> using PQ=priority_queue<T,vector<T>,less<T> >;

void file(){
    freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
    freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
}

/*int s[200005],seg[800005];

void build(int id,int l,int r){
    if(l==r){
        seg[id]=s[l]; return;
    }
    int mid=(l+r)>>1;
    build(id*2,l,mid);
    build(id*2+1,mid+1,r);
    seg[id]=max(seg[id*2],seg[id*2+1]);
}

int ask(int id,int l,int r,int L,int R){
    if(l>R||r<L) return 0;
    if(L<=l&&r<=R) return seg[id];
    int mid=(l+r)>>1;
    return max(ask(id*2,l,mid,L,R),ask(id*2+1,mid+1,r,L,R));
}
 */

ll dp[201][201][2][201],x[201],y[201],t[201];

signed main(){
    AC;
    int n,l; cin>>n>>l;
    FOR(i,1,n+1){
        cin>>x[i]; y[n-i+1]=l-x[i];
    }
    FOR(i,1,n+1) cin>>t[i];
    FOR(i,0,n+1)FOR(j,0,n+1)FOR(k,0,2)FOR(s,0,i+j+1) dp[i][j][k][s]=INF;
    dp[0][0][0][0]=dp[0][0][1][0]=0;
    int ans=0;
    FOR(i,0,n+1)FOR(j,0,n+1){
        if(i+j>n) break;
        FOR(k,0,2)FOR(s,0,min(n,i+j)+1)if(dp[i][j][k][s]!=INF){
            //cout<<"dp["<<i<<"]["<<j<<"]["<<k<<"]["<<s<<"]="<<dp[i][j][k][s]<<endl;
            ans=max(ans,s);
            if(k==0){
                if(dp[i][j][k][s]+x[i+1]-x[i]<=t[i+1]){
                    dp[i+1][j][k][s+1]=min(dp[i+1][j][k][s+1],dp[i][j][k][s]+x[i+1]-x[i]);
                }
                else{
                    dp[i+1][j][k][s]=min(dp[i+1][j][k][s],dp[i][j][k][s]+x[i+1]-x[i]);
                }
                if(dp[i][j][k][s]+y[j+1]+x[i]<=t[n-j]){
                    dp[i][j+1][k^1][s+1]=min(dp[i][j+1][k^1][s+1],dp[i][j][k][s]+y[j+1]+x[i]);
                }
                else{
                    dp[i][j+1][k^1][s]=min(dp[i][j+1][k^1][s],dp[i][j][k][s]+y[j+1]+x[i]);
                }
            }
            else{
                if(dp[i][j][k][s]+x[i+1]+y[j]<=t[i+1]){
                    dp[i+1][j][k^1][s+1]=min(dp[i+1][j][k^1][s+1],dp[i][j][k][s]+x[i+1]+y[j]);
                }
                else{
                    dp[i+1][j][k^1][s]=min(dp[i+1][j][k^1][s],dp[i][j][k][s]+x[i+1]+y[j]);
                }
                if(dp[i][j][k][s]+y[j+1]-y[j]<=t[n-j]){
                    dp[i][j+1][k][s+1]=min(dp[i][j+1][k][s+1],dp[i][j][k][s]+y[j+1]-y[j]);
                }
                else{
                    dp[i][j+1][k][s]=min(dp[i][j+1][k][s],dp[i][j][k][s]+y[j+1]-y[j]);
                }
            }
        }
    }
    cout<<ans<<endl;
}


/*

 */

Compilation message

ho_t3.cpp: In function 'void file()':
ho_t3.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 0 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 0 ms 852 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 1 ms 584 KB Output is correct
28 Correct 1 ms 584 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1096 KB Output is correct
31 Correct 1 ms 1092 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 0 ms 852 KB Output is correct
18 Correct 54 ms 103012 KB Output is correct
19 Correct 33 ms 62600 KB Output is correct
20 Correct 17 ms 33480 KB Output is correct
21 Correct 31 ms 59040 KB Output is correct
22 Correct 37 ms 76500 KB Output is correct
23 Correct 14 ms 28500 KB Output is correct
24 Correct 11 ms 22308 KB Output is correct
25 Correct 14 ms 27860 KB Output is correct
26 Correct 6 ms 10708 KB Output is correct
27 Correct 14 ms 29012 KB Output is correct
28 Correct 10 ms 20692 KB Output is correct
29 Correct 19 ms 29652 KB Output is correct
30 Correct 14 ms 23380 KB Output is correct
31 Correct 14 ms 27948 KB Output is correct
32 Correct 8 ms 14676 KB Output is correct
33 Correct 14 ms 27892 KB Output is correct
34 Correct 4 ms 10068 KB Output is correct
35 Correct 13 ms 27356 KB Output is correct
36 Correct 6 ms 13012 KB Output is correct
37 Correct 14 ms 29012 KB Output is correct
38 Correct 8 ms 15956 KB Output is correct
39 Correct 15 ms 30292 KB Output is correct
40 Correct 9 ms 17840 KB Output is correct
41 Correct 69 ms 126880 KB Output is correct
42 Correct 40 ms 85612 KB Output is correct
43 Correct 66 ms 126796 KB Output is correct
44 Correct 39 ms 84556 KB Output is correct
45 Correct 66 ms 126776 KB Output is correct
46 Correct 38 ms 85624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 0 ms 852 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 1 ms 980 KB Output is correct
27 Correct 1 ms 584 KB Output is correct
28 Correct 1 ms 584 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1096 KB Output is correct
31 Correct 1 ms 1092 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 1 ms 1108 KB Output is correct
36 Correct 54 ms 103012 KB Output is correct
37 Correct 33 ms 62600 KB Output is correct
38 Correct 17 ms 33480 KB Output is correct
39 Correct 31 ms 59040 KB Output is correct
40 Correct 37 ms 76500 KB Output is correct
41 Correct 14 ms 28500 KB Output is correct
42 Correct 11 ms 22308 KB Output is correct
43 Correct 14 ms 27860 KB Output is correct
44 Correct 6 ms 10708 KB Output is correct
45 Correct 14 ms 29012 KB Output is correct
46 Correct 10 ms 20692 KB Output is correct
47 Correct 19 ms 29652 KB Output is correct
48 Correct 14 ms 23380 KB Output is correct
49 Correct 14 ms 27948 KB Output is correct
50 Correct 8 ms 14676 KB Output is correct
51 Correct 14 ms 27892 KB Output is correct
52 Correct 4 ms 10068 KB Output is correct
53 Correct 13 ms 27356 KB Output is correct
54 Correct 6 ms 13012 KB Output is correct
55 Correct 14 ms 29012 KB Output is correct
56 Correct 8 ms 15956 KB Output is correct
57 Correct 15 ms 30292 KB Output is correct
58 Correct 9 ms 17840 KB Output is correct
59 Correct 69 ms 126880 KB Output is correct
60 Correct 40 ms 85612 KB Output is correct
61 Correct 66 ms 126796 KB Output is correct
62 Correct 39 ms 84556 KB Output is correct
63 Correct 66 ms 126776 KB Output is correct
64 Correct 38 ms 85624 KB Output is correct
65 Correct 58 ms 114712 KB Output is correct
66 Correct 55 ms 105284 KB Output is correct
67 Correct 50 ms 100792 KB Output is correct
68 Correct 51 ms 93004 KB Output is correct
69 Correct 58 ms 113596 KB Output is correct
70 Correct 65 ms 108968 KB Output is correct
71 Correct 54 ms 109952 KB Output is correct
72 Correct 65 ms 111236 KB Output is correct
73 Correct 49 ms 103092 KB Output is correct
74 Correct 59 ms 96388 KB Output is correct
75 Correct 53 ms 106524 KB Output is correct
76 Correct 70 ms 122140 KB Output is correct
77 Correct 60 ms 122060 KB Output is correct
78 Correct 50 ms 94188 KB Output is correct
79 Correct 56 ms 97552 KB Output is correct
80 Correct 63 ms 119576 KB Output is correct
81 Correct 47 ms 98576 KB Output is correct
82 Correct 58 ms 104180 KB Output is correct
83 Correct 66 ms 126816 KB Output is correct
84 Correct 57 ms 108836 KB Output is correct
85 Correct 56 ms 118348 KB Output is correct
86 Correct 58 ms 115956 KB Output is correct
87 Correct 55 ms 106516 KB Output is correct
88 Runtime error 176 ms 258292 KB Execution killed with signal 11
89 Halted 0 ms 0 KB -