Submission #155989

# Submission time Handle Problem Language Result Execution time Memory
155989 2019-10-02T13:57:32 Z ASDF123 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 48112 KB
#include <bits/stdc++.h>
#define fr first
#define sc 
using namespace std;

const int N = (int)1e6 + 5;
const int INF = 1e9 + 7;
const int MOD = (int)1e9 + 7;
int n, l, r, k, tests;
int a[N];


void solve() {
  scanf("%d%d%d", &l, &r, &k);
  set <int> st;
  set <int> ::iterator it;
  bool ok = true;
  int mn = INF;

  for (int i = r; i >= l; i--) {
    if (i == r) {
      st.insert(a[i]);
      mn = min(mn, a[i]);
      continue;
    }
    if (mn < a[i]) {
      it = st.lower_bound(a[i]);
      it--;
      if (*it + a[i] > k) {
        ok = false;
        break;
      }
    }
    st.insert(a[i]);
    mn = min(mn, a[i]);
  }

  if (ok) {
    puts("1");
  } else {
    puts("0");
  }
}

main() {
  scanf("%d%d", &n, &tests);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  while (tests--) {
    solve();
  }
}

Compilation message

sortbooks.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
sortbooks.cpp: In function 'void solve()':
sortbooks.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &l, &r, &k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &tests);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 13 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 13 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 8 ms 504 KB Output is correct
12 Correct 12 ms 504 KB Output is correct
13 Correct 13 ms 504 KB Output is correct
14 Correct 19 ms 632 KB Output is correct
15 Correct 16 ms 632 KB Output is correct
16 Correct 1455 ms 852 KB Output is correct
17 Correct 781 ms 700 KB Output is correct
18 Correct 129 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 837 ms 18148 KB Output is correct
2 Correct 858 ms 18564 KB Output is correct
3 Correct 845 ms 18308 KB Output is correct
4 Correct 838 ms 18492 KB Output is correct
5 Execution timed out 3105 ms 48112 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3004 ms 1436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 13 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 8 ms 504 KB Output is correct
12 Correct 12 ms 504 KB Output is correct
13 Correct 13 ms 504 KB Output is correct
14 Correct 19 ms 632 KB Output is correct
15 Correct 16 ms 632 KB Output is correct
16 Correct 1455 ms 852 KB Output is correct
17 Correct 781 ms 700 KB Output is correct
18 Correct 129 ms 504 KB Output is correct
19 Execution timed out 3021 ms 12256 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 13 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 8 ms 504 KB Output is correct
12 Correct 12 ms 504 KB Output is correct
13 Correct 13 ms 504 KB Output is correct
14 Correct 19 ms 632 KB Output is correct
15 Correct 16 ms 632 KB Output is correct
16 Correct 1455 ms 852 KB Output is correct
17 Correct 781 ms 700 KB Output is correct
18 Correct 129 ms 504 KB Output is correct
19 Correct 837 ms 18148 KB Output is correct
20 Correct 858 ms 18564 KB Output is correct
21 Correct 845 ms 18308 KB Output is correct
22 Correct 838 ms 18492 KB Output is correct
23 Execution timed out 3105 ms 48112 KB Time limit exceeded