| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 37814 | mirbek01 | 금 캐기 (IZhO14_divide) | C++14 | 169 ms | 21548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
# define pb push_back
# define fr first
# define sc second
# define mk make_pair
using namespace std;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
typedef long long ll;
int n, a[N];
ll ans, b[N], c[N];
void dv(int l, int r, int opl, int opr)
{
if(l > r) return ;
int md = (l + r) >> 1;;
ll opt, res = 0;
for(int i = opl; i <= min(md, opr); i ++)
{
res = b[md] - b[i - 1];
ll sum = c[md] - c[i - 1];
opt = i;
if(sum >= a[md] - a[i])
break;
}
ans = max(ans, res);
dv(l, md - 1, opl, opt);
dv(md + 1, r, opt, opr);
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> a[i] >> b[i] >> c[i];
b[i] += b[i - 1];
c[i] += c[i - 1];
}
dv(1, n, 1, n);
// for(int i = 1; i <= n; i ++)
// {
// for(int j = 1; j <= i; j ++)
// {
// ll res = b[i] - b[j - 1], sum = c[i] - c[j - 1];
// if(sum < a[i] - a[j]) continue;
// ans = max(ans, res);
// break;
// }
// }
cout << ans << endl;
}
컴파일 시 표준 에러 (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... | ||||
