Submission #524331

# Submission time Handle Problem Language Result Execution time Memory
524331 2022-02-09T04:24:54 Z AzamatRustamov Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
Compilation error
0 ms 0 KB
#include <stdio.h>
using namespace std;

// pair - sort
//

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    scanf("%d %d", &n, &m);

    int w[n+1];
    w[0] = 0;

    for (int i=1; i<=n; i++) scanf("%d", &w[i]);
    for (int i=0; i<m; i++)
    {
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);

        bool can = 1;
        for (int i = l; can && i < r; i++)
            for (int j = i+1; can && j <= r; j++)
                if (w[i]>w[j] && w[i]+w[j]>k)
                    can = 0;

        printf("%d\n", can);
    }

    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:9:5: error: 'ios_base' has not been declared
    9 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
sortbooks.cpp:10:5: error: 'cin' was not declared in this scope
   10 |     cin.tie(0);
      |     ^~~
sortbooks.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include <stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
sortbooks.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
sortbooks.cpp:18:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     for (int i=1; i<=n; i++) scanf("%d", &w[i]);
      |                              ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d %d %d", &l, &r, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~