답안 #897295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897295 2024-01-02T21:18:49 Z ErJ 봉쇄 시간 (IOI23_closing) C++17
0 / 100
1000 ms 1699320 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<pair<ll, ll>>
#define pp pair<ll, ll>
#define qi queue<ll>
#define qp queue<pp>
#define pqi priority_queue<ll>
#define pqp priority_queue<pp>
#define mi map<ll, ll>
#define mpi map<pp, ll>
#define mip map<ll, pp>
#define mpp map<pp, pp>
#define mb map<ll, bool>
#define si set<ll>
#define sp set<pp>
#define mod 1000000007
#define rep(a, b) for(int a = 0; a < (b); a++)
#define inf 1000000000000000000

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int>  V, vector<int> W) {
    vector<ll> distX(N);
    vector<ll> distY(N);
    vector<ll> distXY(N);
    vector<ll> distXY2(N);
    distX[X] = 0;
    distX[Y] = 0;
    for (int i = X + 1; i < N; i++) {
        distX[i] = distX[i - 1] + W[i - 1];
    }
    for (int i = X - 1; i >= 0; i--) {
        distX[i] = distX[i + 1] + W[i];
    }
    for (int i = Y + 1; i < N; i++) {
        distY[i] = distY[i - 1] + W[i - 1];
    }
    for (int i = Y - 1; i >= 0; i--) {
        distY[i] = distY[i + 1] + W[i];
    }
    for (int i = 0; i < N; i++) {
        distXY[i] = max(distX[i], distY[i]);
        distXY2[i] = min(distX[i], distY[i]);
    }

    vvi dp(N + 1);
    dp[0].resize(2*N + 1);
    for (int i = 0; i < 2 * N + 1; i++) {
        dp[0][i] = inf;
    }
    dp[0][0] = 0;
    for (int i = 1; i < dp.size(); i++) {
        dp[i].resize(2 * N + 1);
        for (int j = 0; j < 2 * N + 1; j++) {
            dp[i][j] = dp[i - 1][j];
        }
        for (int j = 0; j < 2 * N + 1; j++) {
            if (dp[i - 1][j] != inf) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + distXY2[i - 1]);
                dp[i][j + 2] = min(dp[i][j + 2], dp[i - 1][j] + distXY[i - 1]);
            }
        }
    }
    int ans = 0;
    for (int i = 2 * N; i >= 0; i--) {
        if (dp[N][i] <= K) {
            ans = i;
            break;
        }
    }
    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 1; i < dp.size(); i++) {
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 1699320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -