답안 #596925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596925 2022-07-15T09:25:02 Z ioi Collecting Stamps 3 (JOI20_ho_t3) C++14
5 / 100
133 ms 196604 KB
#include<bits/stdc++.h>

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("cardgame.in" , "r" , stdin);
#define outF freopen("cardgame.out" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long

#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);

//#define int ll

const int N =  202 ,  M = N * 4  , MX = 2e4 + 40;
const ll MOD = 998244353  , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;

int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , 1 , -1};

int n , l ;
int x[N] , t[N];

int dp[N][N][N][3];

int calc(int i , int j , int tim , int now){

  //  cout << i << " " << j << " " << tim << " " << now << endl ;

    if(i > j)return 0 ;


    int &ret = dp[i][j][tim][now];
    if(~ret)
        return ret ;



    if(now == 0){

        ret = calc(i , j - 1 , tim + x[j + 1] - x[j] , 0) + (tim + x[j + 1] - x[j] <= t[j]);

        ret = max(ret , calc(i + 1 , j , tim + l - x[j + 1] + x[i] , 2) + (tim + l - x[j + 1] + x[i] <= t[i]));

    }
    else if(now == 1){

        ret = calc(i + 1 , j ,x[i] , 2) + (x[i] <= t[i]);
        ret = max(ret , calc(i , j - 1 , l - x[j] , 0) + (l - x[j] <= t[j]));


    }
    else {

        ret = calc(i + 1 , j , tim + x[i] - x[i - 1] , 2) + (tim + x[i] - x[i - 1] <= t[i]);
        ret = max(ret , calc(i , j - 1 , tim + x[i - 1] + l - x[j] , 0) + (tim + x[i - 1] + l - x[j] <= t[j]));

    }

    return ret ;


}


int32_t main()
{
    // inF;
   // inF;outF;
    fastio;

    //Welcome back without <TAWJIHI>


    cin >> n >> l ;

    memset(dp , -1 , sizeof dp);


    for(int i = 0 ; i < n ; i ++)cin >> x[i];

    for(int i = 0 ; i < n ; i ++)cin >> t[i];


    cout << calc(0 , n - 1 , 0 , 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 96972 KB Output is correct
2 Correct 38 ms 96996 KB Output is correct
3 Correct 38 ms 96960 KB Output is correct
4 Correct 37 ms 97064 KB Output is correct
5 Correct 41 ms 97024 KB Output is correct
6 Correct 42 ms 96972 KB Output is correct
7 Correct 47 ms 97016 KB Output is correct
8 Correct 37 ms 97040 KB Output is correct
9 Correct 38 ms 96972 KB Output is correct
10 Correct 42 ms 97084 KB Output is correct
11 Correct 38 ms 96964 KB Output is correct
12 Correct 39 ms 97028 KB Output is correct
13 Correct 37 ms 97060 KB Output is correct
14 Correct 43 ms 97064 KB Output is correct
15 Correct 37 ms 97068 KB Output is correct
16 Correct 38 ms 96972 KB Output is correct
17 Correct 37 ms 96972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 96972 KB Output is correct
2 Correct 38 ms 96996 KB Output is correct
3 Correct 38 ms 96960 KB Output is correct
4 Correct 37 ms 97064 KB Output is correct
5 Correct 41 ms 97024 KB Output is correct
6 Correct 42 ms 96972 KB Output is correct
7 Correct 47 ms 97016 KB Output is correct
8 Correct 37 ms 97040 KB Output is correct
9 Correct 38 ms 96972 KB Output is correct
10 Correct 42 ms 97084 KB Output is correct
11 Correct 38 ms 96964 KB Output is correct
12 Correct 39 ms 97028 KB Output is correct
13 Correct 37 ms 97060 KB Output is correct
14 Correct 43 ms 97064 KB Output is correct
15 Correct 37 ms 97068 KB Output is correct
16 Correct 38 ms 96972 KB Output is correct
17 Correct 37 ms 96972 KB Output is correct
18 Runtime error 133 ms 196604 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 96972 KB Output is correct
2 Correct 38 ms 96996 KB Output is correct
3 Correct 38 ms 96960 KB Output is correct
4 Correct 37 ms 97064 KB Output is correct
5 Correct 41 ms 97024 KB Output is correct
6 Correct 42 ms 96972 KB Output is correct
7 Correct 47 ms 97016 KB Output is correct
8 Correct 37 ms 97040 KB Output is correct
9 Correct 38 ms 96972 KB Output is correct
10 Correct 42 ms 97084 KB Output is correct
11 Correct 38 ms 96964 KB Output is correct
12 Correct 39 ms 97028 KB Output is correct
13 Correct 37 ms 97060 KB Output is correct
14 Correct 43 ms 97064 KB Output is correct
15 Correct 37 ms 97068 KB Output is correct
16 Correct 38 ms 96972 KB Output is correct
17 Correct 37 ms 96972 KB Output is correct
18 Incorrect 129 ms 97096 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 96972 KB Output is correct
2 Correct 38 ms 96996 KB Output is correct
3 Correct 38 ms 96960 KB Output is correct
4 Correct 37 ms 97064 KB Output is correct
5 Correct 41 ms 97024 KB Output is correct
6 Correct 42 ms 96972 KB Output is correct
7 Correct 47 ms 97016 KB Output is correct
8 Correct 37 ms 97040 KB Output is correct
9 Correct 38 ms 96972 KB Output is correct
10 Correct 42 ms 97084 KB Output is correct
11 Correct 38 ms 96964 KB Output is correct
12 Correct 39 ms 97028 KB Output is correct
13 Correct 37 ms 97060 KB Output is correct
14 Correct 43 ms 97064 KB Output is correct
15 Correct 37 ms 97068 KB Output is correct
16 Correct 38 ms 96972 KB Output is correct
17 Correct 37 ms 96972 KB Output is correct
18 Runtime error 133 ms 196604 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -