제출 #344137

#제출 시각아이디문제언어결과실행 시간메모리
344137NurlykhanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3081 ms4332 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e6 + 10;

int n, m;
int w[N];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &w[i]);
    }
    while (m--) {
        int l, r, k;
        scanf("%d%d%d", &l, &r, &k);
        int mx = 0, mxx = 0;
        stack<int> s;
        for (int i = r; i >= l; i--) {
            while (!s.empty() && s.top() < w[i]) {
                mx = max(mx, s.top() + w[i]);
                s.pop();
            }
            if (s.empty() || s.top() > w[i])
                s.push(w[i]);
        }
        if (k >= mx) {
            printf("1\n");
        } else {
            printf("0\n");
        }
    }
    return 0;
}

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

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:18:21: warning: unused variable 'mxx' [-Wunused-variable]
   18 |         int mx = 0, mxx = 0;
      |                     ^~~
sortbooks.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         scanf("%d", &w[i]);
      |         ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d%d%d", &l, &r, &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...