답안 #898123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898123 2024-01-04T10:39:59 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
695 ms 64124 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define tp3 tuple<int, int, int>

const int N = 1e6+6, inf = INT_MAX;

int n, m, mnA, mxA, mxK, a[N];
//vector<int> pos[N];
vector<tp3> q[N];
bitset<N> ans;

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> m;
  mnA = inf;
  mxA = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mnA = min(mnA, a[i]);
    mxA = max(mxA, a[i]);
    //pos[a[i]].push_back(i);
  }

  mxK = 0;
  for (int i = 0; i < m; i++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--; r--;
    mxK = max(mxK, k);
    q[l].push_back(make_tuple(r, k, i));
  }

  if (max(n, m) <= 5000) {
    for (int l = 0; l < n; l++) {
      sort(all(q[l]));

      int r = l;
      int mx = a[l];
      int mxSum = 0;
      for (auto& [nwR, k, idx] : q[l]) {
        while (r < nwR) {
          r++;
          mx = max(mx, a[r]);
          mxSum = max(mxSum, (mx > a[r] ? mx+a[r] : 0));
        }
        ans[idx] = (mxSum <= k);
      }
    }
  }

  if (mxK < mnA) {
    vector<int> b;
    b.push_back(0);
    for (int i = 1; i < n; i++) {
      if (a[i] < a[i-1]) {
        b.push_back(i);
      }
    }

    for (int l = 0; l < n; l++) {
      sort(all(q[l]));

      for (auto& [r, k, idx] : q[l]) {
        int x = upper_bound(all(b), l) - b.begin();
        int y = upper_bound(all(b), l) - b.begin();
        ans[idx] = (x == y);
      }
    }
  }

/*
  if (mxA <= 1000) {
    for (int l = 0; l < n; l++) {
      sort(all(q[l]));

      for (auto& [r, k, idx] : q[l]) {
        int x = upper_bound(all(b), l) - b.begin();
        int y = upper_bound(all(b), l) - b.begin();
        ans[idx] = (x == y);
      }
    }
  }
  */

  for (int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 24924 KB Output is correct
2 Correct 5 ms 25336 KB Output is correct
3 Correct 6 ms 24924 KB Output is correct
4 Correct 5 ms 24920 KB Output is correct
5 Correct 6 ms 24924 KB Output is correct
6 Correct 6 ms 25096 KB Output is correct
7 Correct 6 ms 24924 KB Output is correct
8 Correct 7 ms 24924 KB Output is correct
9 Correct 5 ms 24924 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 24924 KB Output is correct
2 Correct 5 ms 25336 KB Output is correct
3 Correct 6 ms 24924 KB Output is correct
4 Correct 5 ms 24920 KB Output is correct
5 Correct 6 ms 24924 KB Output is correct
6 Correct 6 ms 25096 KB Output is correct
7 Correct 6 ms 24924 KB Output is correct
8 Correct 7 ms 24924 KB Output is correct
9 Correct 5 ms 24924 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 7 ms 25096 KB Output is correct
12 Correct 10 ms 25180 KB Output is correct
13 Correct 10 ms 25180 KB Output is correct
14 Correct 13 ms 25180 KB Output is correct
15 Correct 12 ms 25180 KB Output is correct
16 Correct 12 ms 25180 KB Output is correct
17 Correct 10 ms 25176 KB Output is correct
18 Correct 14 ms 25160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 695 ms 64124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 27556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 24924 KB Output is correct
2 Correct 5 ms 25336 KB Output is correct
3 Correct 6 ms 24924 KB Output is correct
4 Correct 5 ms 24920 KB Output is correct
5 Correct 6 ms 24924 KB Output is correct
6 Correct 6 ms 25096 KB Output is correct
7 Correct 6 ms 24924 KB Output is correct
8 Correct 7 ms 24924 KB Output is correct
9 Correct 5 ms 24924 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 7 ms 25096 KB Output is correct
12 Correct 10 ms 25180 KB Output is correct
13 Correct 10 ms 25180 KB Output is correct
14 Correct 13 ms 25180 KB Output is correct
15 Correct 12 ms 25180 KB Output is correct
16 Correct 12 ms 25180 KB Output is correct
17 Correct 10 ms 25176 KB Output is correct
18 Correct 14 ms 25160 KB Output is correct
19 Incorrect 117 ms 36432 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 24924 KB Output is correct
2 Correct 5 ms 25336 KB Output is correct
3 Correct 6 ms 24924 KB Output is correct
4 Correct 5 ms 24920 KB Output is correct
5 Correct 6 ms 24924 KB Output is correct
6 Correct 6 ms 25096 KB Output is correct
7 Correct 6 ms 24924 KB Output is correct
8 Correct 7 ms 24924 KB Output is correct
9 Correct 5 ms 24924 KB Output is correct
10 Correct 5 ms 24924 KB Output is correct
11 Correct 7 ms 25096 KB Output is correct
12 Correct 10 ms 25180 KB Output is correct
13 Correct 10 ms 25180 KB Output is correct
14 Correct 13 ms 25180 KB Output is correct
15 Correct 12 ms 25180 KB Output is correct
16 Correct 12 ms 25180 KB Output is correct
17 Correct 10 ms 25176 KB Output is correct
18 Correct 14 ms 25160 KB Output is correct
19 Incorrect 695 ms 64124 KB Output isn't correct
20 Halted 0 ms 0 KB -