Submission #1040982

# Submission time Handle Problem Language Result Execution time Memory
1040982 2024-08-01T13:22:15 Z Zicrus Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 14420 KB
#include <bits/stdc++.h>
#include "closing.h"
using namespace std;
 
typedef long long ll;
 
int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) {
    vector<ll> distX(n), distY(n), totX(n), totY(n);
    for (int i = x-1; i >= 0; i--) {
        distX[i] = distX[i+1] + w[i];
        totX[i] = totX[i+1] + distX[i];
    }
    for (int i = x+1; i < n; i++) {
        distX[i] = distX[i-1] + w[i-1];
        totX[i] = totX[i-1] + distX[i];
    }
    for (int i = y-1; i >= 0; i--) {
        distY[i] = distY[i+1] + w[i];
        totY[i] = totY[i+1] + distY[i];
    }
    for (int i = y+1; i < n; i++) {
        distY[i] = distY[i-1] + w[i-1];
        totY[i] = totY[i-1] + distY[i];
    }
    vector<ll> mx(n), mxSum(n+1);
    for (int i = 0; i < n; i++) {
        mx[i] = max(distX[i], distY[i]);
        mxSum[i+1] = mxSum[i] + mx[i];
    }

    ll res = 0;
    for (int x1 = 0; x1 <= x; x1++) {
        for (int y1 = x1; y1 <= y; y1++) {
            for (int y2 = y; y2 < n; y2++) {
                for (int x2 = x; x2 <= y2; x2++) {
                    ll val = x2-x1+1 + y2-y1+1;
                    if (val <= res) continue;

                    ll cost = 1ll << 62ll;
                    if (x2 < y1) {
                        cost = totX[x1] + totX[x2] + totY[y1] + totY[y2];
                    }
                    else {
                        cost = totX[x1] + (y1-1 < x ? -totX[y1-1] : totX[y1-1]) + (x2+1 > y ? -totY[x2+1] : totY[x2+1]) + totY[y2]
                             + (mxSum[x2+1] - mxSum[y1]);
                    }
                    
                    if (cost <= k) res = val;
                    else break;
                }
            }
        }
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 14420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '6'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '6'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '6'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '14'
2 Halted 0 ms 0 KB -