답안 #874430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874430 2023-11-17T03:31:20 Z Maite_Morale Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
179 ms 263312 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 205
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>

ll dp[MAX][410][MAX][5],a[MAX],t[MAX],n,m;   
int main(){
    cin>>n>>m;a[n]=m;t[n]=0;
    for(int i=0;i<n;i++){
        cin>>a[i];a[i+n+1]=a[i]+m;
    }
    for(int i=0;i<n;i++){
        cin>>t[i];t[i+n+1]=t[i];
    }
    for(int k=0;k<=n;k++)
        for(int i=n;i>=0;i--)
            for(int j=n;j<=i+n;j++)
                dp[i][j][k][0]=dp[i][j][k][1]=oo;
    dp[n][n][0][0]=dp[n][n][0][1]=0;
    ll r=0;
    for(int k=0;k<=n;k++){
        for(int i=n;i>=0;i--){
            for(int j=n;j<=i+n;j++){
                if(dp[i][j][k][0]!=oo){
                    if(j<i+n){
                        ll x=0,y=dp[i][j][k][0]+abs(a[i]-a[j+1]);
                        if(y<=t[j+1])x++;
                        dp[i][j+1][k+x][1]=min(dp[i][j+1][k+x][1],y);
                    }
                    if(i>0){
                        ll x=0,y=dp[i][j][k][0]+abs(a[i]-a[i-1]);
                        if(y<=t[i-1])x++;
                        dp[i-1][j][k+x][0]=min(dp[i-1][j][k+x][0],y);
                    }
                }
                if(dp[i][j][k][1]!=oo){
                    if(j<i+n){
                        ll x=0,y=dp[i][j][k][1]+abs(a[j]-a[j+1]);
                        if(y<=t[j+1])x++;
                        dp[i][j+1][k+x][1]=min(dp[i][j+1][k+x][1],y);
                    }
                    if(i>0){
                        ll x=0,y=dp[i][j][k][1]+abs(a[j]-a[i-1]);
                        if(y<=t[i-1])x++;
                        dp[i-1][j][k+x][0]=min(dp[i-1][j][k+x][0],y);
                    }
                }
                if(dp[i][j][k][1]!=oo || dp[i][j][k][0]!=oo)r=k;
            }
        }
    }cout<<r<<" ";
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 18892 KB Output is correct
4 Correct 1 ms 12636 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 5 ms 26972 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 26972 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 5 ms 27088 KB Output is correct
13 Correct 3 ms 27064 KB Output is correct
14 Correct 2 ms 14684 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 3 ms 27324 KB Output is correct
17 Correct 3 ms 26972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 18892 KB Output is correct
4 Correct 1 ms 12636 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 5 ms 26972 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 26972 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 5 ms 27088 KB Output is correct
13 Correct 3 ms 27064 KB Output is correct
14 Correct 2 ms 14684 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 3 ms 27324 KB Output is correct
17 Correct 3 ms 26972 KB Output is correct
18 Correct 5 ms 33116 KB Output is correct
19 Correct 3 ms 22876 KB Output is correct
20 Correct 3 ms 26972 KB Output is correct
21 Correct 5 ms 33116 KB Output is correct
22 Correct 2 ms 18880 KB Output is correct
23 Correct 5 ms 33116 KB Output is correct
24 Correct 3 ms 29020 KB Output is correct
25 Correct 5 ms 33116 KB Output is correct
26 Correct 4 ms 33112 KB Output is correct
27 Correct 2 ms 16728 KB Output is correct
28 Correct 2 ms 18780 KB Output is correct
29 Correct 3 ms 33116 KB Output is correct
30 Correct 4 ms 33116 KB Output is correct
31 Correct 4 ms 33116 KB Output is correct
32 Correct 3 ms 29020 KB Output is correct
33 Correct 4 ms 33116 KB Output is correct
34 Correct 4 ms 33112 KB Output is correct
35 Correct 4 ms 33116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 18892 KB Output is correct
4 Correct 1 ms 12636 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 5 ms 26972 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 26972 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 5 ms 27088 KB Output is correct
13 Correct 3 ms 27064 KB Output is correct
14 Correct 2 ms 14684 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 3 ms 27324 KB Output is correct
17 Correct 3 ms 26972 KB Output is correct
18 Correct 179 ms 263312 KB Output is correct
19 Incorrect 70 ms 228700 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 2 ms 18892 KB Output is correct
4 Correct 1 ms 12636 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 5 ms 26972 KB Output is correct
7 Correct 2 ms 16732 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 26972 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 5 ms 27088 KB Output is correct
13 Correct 3 ms 27064 KB Output is correct
14 Correct 2 ms 14684 KB Output is correct
15 Correct 2 ms 16732 KB Output is correct
16 Correct 3 ms 27324 KB Output is correct
17 Correct 3 ms 26972 KB Output is correct
18 Correct 5 ms 33116 KB Output is correct
19 Correct 3 ms 22876 KB Output is correct
20 Correct 3 ms 26972 KB Output is correct
21 Correct 5 ms 33116 KB Output is correct
22 Correct 2 ms 18880 KB Output is correct
23 Correct 5 ms 33116 KB Output is correct
24 Correct 3 ms 29020 KB Output is correct
25 Correct 5 ms 33116 KB Output is correct
26 Correct 4 ms 33112 KB Output is correct
27 Correct 2 ms 16728 KB Output is correct
28 Correct 2 ms 18780 KB Output is correct
29 Correct 3 ms 33116 KB Output is correct
30 Correct 4 ms 33116 KB Output is correct
31 Correct 4 ms 33116 KB Output is correct
32 Correct 3 ms 29020 KB Output is correct
33 Correct 4 ms 33116 KB Output is correct
34 Correct 4 ms 33112 KB Output is correct
35 Correct 4 ms 33116 KB Output is correct
36 Correct 179 ms 263312 KB Output is correct
37 Incorrect 70 ms 228700 KB Output isn't correct
38 Halted 0 ms 0 KB -