제출 #333016

#제출 시각아이디문제언어결과실행 시간메모리
333016BoabaHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
100 / 100
1231 ms109104 KiB
#include <cstdio>
#include <vector>
#define Max(a, b) (((a) < (b)) ? (b) : (a))
#pragma GCC optimize ("O3")

const int nmax = 1e6 + 5;

struct day {
    int st, dr, ind, k;
};

int v[nmax], aib[nmax], n, m;
bool ans[nmax];
std::vector<int>st, last[nmax];
std::vector<day>skema[nmax];

void update(int poz, int val) {
    for (; poz <= n; poz += poz & (-poz))
        aib[poz] = Max(aib[poz], val);
}

int query(int poz) {
    int ans = 0;
    for (; poz > 0; poz -= poz & (-poz))
        ans = Max(ans, aib[poz]);
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++){
        scanf("%d", &v[i]);
        while (!st.empty() and v[st.back()] <= v[i]) st.pop_back();
        if (!st.empty()) last[st.back()].push_back(i);
        st.push_back(i);
    }
    for (int i = 1; i <= m; i++) {
        day aux;
        scanf("%d %d %d", &aux.st, &aux.dr, &aux.k);
        aux.ind = i;
        skema[aux.st].push_back(aux);
    }
    for (int i = n; i > 0; i--) {
        for (int x : last[i]) update(x, v[x] + v[i]);
        for (day aux : skema[i]) ans[aux.ind] = (query(aux.dr) <= aux.k);
    }
    for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |         scanf("%d", &v[i]);
      |         ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |         scanf("%d %d %d", &aux.st, &aux.dr, &aux.k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...