Submission #3426658


Source Code Expand

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using Int = long long;
int main()
{
    Int N, C;
    cin >> N >> C;
    vector<Int> X(N+1), V(N+1);
    for (int i = 1; i <= N; i++) cin >> X[i] >> V[i];
    vector<Int> cw(N+1), ccw(N+1);
    vector<bool> cwb(N+1), ccwb(N+1);
    for (int i = 1; i <= N; i++) {
        cw[i] = cw[i-1] + V[i];
        ccw[i] = ccw[i-1] + V[N+1-i];
    }
    Int bestcw = 0, bestccw = 0;
    for (int i = 1; i <= N; i++) {
        Int s = cw[i] - X[i];
        if (s > bestcw) {
            bestcw = s;
            cwb[i] = true;
        }
    }
    for (int i = 1; i <= N; i++) {
        Int s = ccw[i] - (C - X[N+1-i]);
        if (s > bestccw) {
            bestccw = s;
            ccwb[i] = true;
        }
    }
    Int result = max(bestcw, bestccw);
    Int j;
    j = N;
    for (int i = 1; i <= N - 1; i++) {
        j = min(j, N - i);
        while (j > 0 && !ccwb[j]) j--;
        result = max(result, cw[i] - 2*X[i] + ccw[j] - (C - X[N+1-j]));
    }
    j = N;
    for (int i = 1; i <= N - 1; i++) {
        j = min(j, N - i);
        while (j > 0 && !cwb[j]) j--;
        result = max(result, ccw[i] - 2*(C - X[N+1-i]) + cw[j] - X[j]);
    }
    cout << result << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Static Sushi
User ha15
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1330 Byte
Status WA
Exec Time 100 ms
Memory 3456 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 300 0 / 200
Status
AC × 4
AC × 27
WA × 2
AC × 48
WA × 2
Set Name Test Cases
Sample a01, a02, a03, a04
Subtask1 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29
Subtask2 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 WA 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 1 ms 256 KB
b14 WA 1 ms 256 KB
b15 AC 1 ms 256 KB
b16 AC 1 ms 256 KB
b17 AC 1 ms 256 KB
b18 AC 1 ms 256 KB
b19 AC 1 ms 256 KB
b20 AC 1 ms 256 KB
b21 AC 1 ms 256 KB
b22 AC 1 ms 256 KB
b23 AC 1 ms 256 KB
b24 AC 1 ms 256 KB
b25 AC 1 ms 256 KB
b26 AC 1 ms 256 KB
b27 AC 1 ms 256 KB
b28 AC 1 ms 256 KB
b29 AC 1 ms 256 KB
c30 AC 47 ms 3456 KB
c31 AC 76 ms 3456 KB
c32 AC 100 ms 3456 KB
c33 AC 100 ms 3456 KB
c34 AC 100 ms 3456 KB
c35 AC 47 ms 3456 KB
c36 AC 96 ms 3456 KB
c37 AC 92 ms 3456 KB
c38 AC 92 ms 3456 KB
c39 AC 93 ms 3456 KB
c40 AC 94 ms 3456 KB
c41 AC 91 ms 3456 KB
c42 AC 92 ms 3456 KB
c43 AC 10 ms 512 KB
c44 AC 92 ms 3456 KB
c45 AC 2 ms 256 KB
c46 AC 90 ms 3456 KB
c47 AC 1 ms 256 KB
c48 AC 92 ms 3456 KB
c49 AC 91 ms 3456 KB
c50 AC 93 ms 3456 KB