# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90503 | daniel_02 | Divide and conquer (IZhO14_divide) | C++14 | 17 ms | 1304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fr first
#define pb push_back
#define sc second
#define ll long long
using namespace std;
const int N = 5005;
pair<int, pair<int, int>> a[N];
ll pre[N], prg[N], ans;
main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
scanf("%d%d%d", &a[i].fr, &a[i].sc.fr, &a[i].sc.sc);
pre[i] = pre[i - 1] + a[i].sc.sc;
prg[i] = prg[i - 1] + a[i].sc.fr;
}
for (int i = 1; i <= n; i++)
{
for (int j = i; j <= n; j++)
{
if (a[j].fr - a[i].fr <= pre[j] - pre[i - 1])
{
if (ans < prg[j] - prg[i - 1])
{
ans = prg[j] - prg[i - 1];
}
}
}
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |