Submission #252752

# Submission time Handle Problem Language Result Execution time Memory
252752 2020-07-26T08:20:47 Z Vladikus004 Go (COCI18_go) C++14
70 / 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;
    }
    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 256 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 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 0 ms 384 KB Output isn't correct