Submission #252753

# Submission time Handle Problem Language Result Execution time Memory
252753 2020-07-26T08:23:06 Z Vladikus004 Go (COCI18_go) C++14
80 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int M = 100 + 3, T = 2000 + 3, N = 1000 + 3;
int n, k, m, a[M], b[M], t[M], ind;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif // LOCAL
    cin >> n >> k >> m;
    ind = -1;
    for (int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> t[i];
        if (a[i] > k && ind == -1) ind = i;
    }
    if (ind == -1) ind = m;
    int IND = ind;
    --ind;
    int sum = 0, mx = 0;
    while (ind >= 0){
        if (t[ind] > k - a[ind]) sum += b[ind];
        int now = 0;
        for (int j = IND; j < m; j++){
            if (k - a[ind] + a[j] - a[ind] < t[j]){
                now += b[j];
            }
        }
        mx = max(mx, now + sum);
        ind--;
    }

    int now = 0;
    for (int i = IND; i < m; i++){
        if (a[i] - k < t[i])
            now += b[i];
    }
    mx = max(mx, now);

    ind = IND;
    sum = 0;
    while (ind < m){
        if (t[ind] > a[ind] - k) sum += b[ind];
        int now = 0;
        for (int j = IND - 1; j >= 0; j--){
            if (a[ind] - k + a[ind] - a[j] < t[j]){
                now += b[j];
            }
        }
        mx = max(mx, now + sum);
        ind++;
    }
    cout << mx;
}///123
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Incorrect 0 ms 384 KB Output isn't correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Incorrect 0 ms 384 KB Output isn't correct