Submission #3729940


Source Code Expand

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto X = new long[](N);
    auto S = new long[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        X[i] = s[0];
        S[i] = s[1];
    }

    long[] Y;
    foreach (i; 0..N) {
        Y ~= S[i];
        if (i < N - 1) Y ~= X[i] - X[i+1];
    }

    long ans = 0;
    long tmp = 0;

    for (int i = 0, j = 0; i < N * 2 - 1; ++i) {
        if (j < i) {
            j = i;
            tmp = 0;
        }
        while (j < N * 2 - 1 && tmp + Y[j] >= 0) {
            tmp += Y[j];
            ++j;
            ans = max(ans, tmp);
        }
    }

    ans.writeln;
}

Submission Info

Submission Time
Task F - Capture
User nebukuro09
Language D (LDC 0.17.0)
Score 100
Code Size 883 Byte
Status AC
Exec Time 186 ms
Memory 10492 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 33
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, 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, b30, b31, b32, b33
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 178 ms 9852 KB
b06 AC 177 ms 9852 KB
b07 AC 138 ms 10364 KB
b08 AC 123 ms 9084 KB
b09 AC 123 ms 8828 KB
b10 AC 143 ms 9852 KB
b11 AC 145 ms 10492 KB
b12 AC 142 ms 9084 KB
b13 AC 141 ms 9212 KB
b14 AC 142 ms 10364 KB
b15 AC 139 ms 9084 KB
b16 AC 138 ms 8700 KB
b17 AC 138 ms 10108 KB
b18 AC 173 ms 10364 KB
b19 AC 135 ms 8572 KB
b20 AC 169 ms 9980 KB
b21 AC 173 ms 8828 KB
b22 AC 174 ms 8700 KB
b23 AC 174 ms 9596 KB
b24 AC 143 ms 10236 KB
b25 AC 140 ms 9212 KB
b26 AC 139 ms 8828 KB
b27 AC 142 ms 8956 KB
b28 AC 139 ms 9468 KB
b29 AC 138 ms 8572 KB
b30 AC 174 ms 9340 KB
b31 AC 134 ms 9596 KB
b32 AC 186 ms 10364 KB
b33 AC 176 ms 10492 KB