답안 #96219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96219 2019-02-07T08:35:01 Z Kastanda 금 캐기 (IZhO14_divide) C++11
100 / 100
58 ms 7664 KB
#include<bits/stdc++.h>
#define lc (id << 1)
#define rc (id << 1 ^ 1)
#define md ((l + r) >> 1)
using namespace std;
typedef long long ll;
const int N = 100005;
int n;
ll D[N], E[N], G[N], MN[N * 4];
void Build(int id = 1, int l = 0, int r = n + 1)
{
    if (r - l < 2)
    {
        MN[id] = D[l] - E[l];
        return ;
    }
    Build(lc, l, md);
    Build(rc, md, r);
    MN[id] = min(MN[lc], MN[rc]);
}
int Get(ll val, int id = 1, int l = 0, int r = n + 1)
{
    if (MN[id] > val)
        return (-1);
    if (r - l < 2)
        return (l);
    int i = Get(val, rc, md, r);
    if (i != -1) return (i);
    return (Get(val, lc, l, md));
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld%lld%lld", &D[i], &G[i], &E[i]);
        E[i] += E[i - 1]; G[i] += G[i - 1];
    }
    D[0] = -1e17;
    Build();
    ll Max = 0;
    for (int i = 1; i <= n; i++)
    {
        int j = Get(D[i] - E[i - 1]);
        if (j >= i)
            Max = max(Max, G[j] - G[i - 1]);
    }
    return !printf("%lld\n", Max);
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
divide.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld", &D[i], &G[i], &E[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 10 ms 420 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 420 KB Output is correct
8 Correct 2 ms 372 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 372 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 6 ms 1060 KB Output is correct
4 Correct 23 ms 3576 KB Output is correct
5 Correct 30 ms 3912 KB Output is correct
6 Correct 58 ms 7664 KB Output is correct
7 Correct 44 ms 6520 KB Output is correct
8 Correct 42 ms 6620 KB Output is correct
9 Correct 56 ms 6492 KB Output is correct
10 Correct 46 ms 6496 KB Output is correct
11 Correct 55 ms 6900 KB Output is correct
12 Correct 54 ms 7288 KB Output is correct