Submission #97463

#TimeUsernameProblemLanguageResultExecution timeMemory
97463Kastanda거래 (IZhO13_trading)C++11
0 / 100
7 ms4992 KiB
// I do it for the glory
#include<bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, q, best[N * 4];
void Add(int le, int ri, int st, int id = 1, int l = 0, int r = n)
{
    if (ri <= l || r <= le)
        return ;
    if (le <= l && r <= ri)
    {
        best[id] = st + l - le;
        return ;
    }
    Add(le, ri, st, id + id, l, (l + r) >> 1);
    Add(le, ri, st, id + id + 1, (l + r) >> 1, r);
}
void DFS(int id = 1, int l = 0, int r = n)
{
    if (r - l < 2)
    {
        printf("%d ", max(best[id], 0));
        return ;
    }
    best[id + id] = max(best[id + id], best[id]);
    best[id + id + 1] = max(best[id + id + 1], best[id] + ((l + r) >> 1) - l);
    DFS(id + id, l, (l + r) >> 1);
    DFS(id + id + 1, (l + r) >> 1, r);
}
int main()
{
    scanf("%d%d", &n, &q);
    memset(best, -63, sizeof(best));
    for (; q; q --)
    {
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        Add(l - 1, r, x);
    }
    DFS();
    return 0;
}

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~
trading.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &l, &r, &x);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...