Submission #252753

#TimeUsernameProblemLanguageResultExecution timeMemory
252753Vladikus004Go (COCI18_go)C++14
80 / 100
1 ms384 KiB
#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 timeMemoryGrader output
Fetching results...