Submission #83093

# Submission time Handle Problem Language Result Execution time Memory
83093 2018-11-05T08:17:29 Z chunghan 막대기 (KOI13_game) C++17
0 / 100
1000 ms 2212 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long int lld;
typedef pair<int, int> pii;

int N, L;
vector<pii> S;
lld D[100005];

lld solve(int p) {
    if(D[p] != -1) return D[p];
    lld ret = 0;
    for(int i = 0; i < p; i++) {
        if(S[i].second == S[p].second)
            ret = max(ret, solve(i));
        if(S[i].first == S[p].first && S[i].second < S[p].second)
            ret = max(ret, solve(i));
    }
    return D[p] = ret + abs(S[p].first - S[p].second) + L;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    memset(D, -1, sizeof(D));
    cin >> N >> L;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        S.push_back(pii(x, y));
    }
    sort(S.begin(), S.end());
    lld rst = 0;
    for(int i = 0; i < N; i++) rst = max(rst, solve(i));
    cout << rst;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Incorrect 3 ms 1280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2212 KB Output is correct
2 Incorrect 2 ms 2212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 2212 KB Output isn't correct
2 Halted 0 ms 0 KB -