답안 #1104164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104164 2024-10-23T04:45:15 Z Nxmkxing 봉쇄 시간 (IOI23_closing) C++17
0 / 100
45 ms 14940 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int M = 1e5 + 10;
ll n, x, y, p, qs[M], a[M], b[M];

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    n = N, x = X, y = Y, p = K;
    for (int i = 0; i < n - 1; i++) {
        qs[i+1] = qs[i] + W[i];
    }
    if (x > y) swap(x, y);
    for (int i = 0; i <= x; i++) {
        a[i] = qs[x] - qs[i];
    }
    for (int i = y; i < n; i++) {
        a[i] = qs[i] - qs[y];
    }
    for (int i = x; i <= y; i++) {
        a[i] = min(qs[i] - qs[x], qs[y] - qs[i]);
        b[i] = max(qs[i] - qs[x], qs[y] - qs[i]) - a[i];
    }
    for (int i = 1; i < n; i++) {
        a[i] += a[i-1];
        b[i] += b[i-1];
    }
    int ans = 0;
    for (int i = 0; i <= x; i++) {
        for (int j = y; j < n; j++) {
            ll sum = a[j] - (i > 0 ? a[i-1] : 0);
            int lv1 = j - i + 1;
            if (sum <= p) ans = max(ans, lv1);
            for (int k = x + 1; k < y; k++) {
                for (int l = k; l < y; l++) {
                    ll rollback = a[l] - a[k-1];
                    ll upd = b[l] - b[k-1];
                    int lv2 = l - k + 1;
                    if (sum - rollback <= p) {
                        ans = max(ans, lv1 - lv2);
                    }
                    if (sum + upd <= p) {
                        ans = max(ans, lv1 + lv2);
                    }
                }
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 45 ms 14940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 452 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 452 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 452 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -