답안 #569691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
569691 2022-05-27T15:57:33 Z SSRS Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
3000 ms 82632 KB
#include <bits/stdc++.h>
using namespace std;
const long long INF1 = 1000000000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<long long> w(N);
  for (int i = 0; i < N; i++){
    cin >> w[i];
  }
  vector<int> l(M), r(M);
  vector<long long> k(M);
  for (int i = 0; i < M; i++){
    cin >> l[i] >> r[i] >> k[i];
    l[i]--;
  }
  vector<vector<int>> query(N);
  for (int i = 0; i < M; i++){
    query[l[i]].push_back(i);
  }
  vector<long long> ST = w;
  stack<int> st;
  st.push(N);
  vector<long long> mx(M, 0);
  for (int i = N - 1; i >= 0; i--){
    while (st.top() != N){
      int p = st.top();
      if (w[i] <= w[p]){
        break;
      }
      st.pop();
      int q = st.top();
      ST[p] += INF1;
      for (int j = p + 1; j < q; j++){
        ST[j] -= w[p];
      }
    }
    int p = st.top();
    ST[i] -= INF1;
    for (int j = i + 1; j < p; j++){
      ST[j] += w[i];
    }
    st.push(i);
    for (int j : query[i]){
      for (int p = i; p < r[j]; p++){
        mx[j] = max(mx[j], ST[p]);
      }
    }
  }
  for (int i = 0; i < M; i++){
    if (mx[i] <= k[i]){
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 10 ms 468 KB Output is correct
12 Correct 14 ms 596 KB Output is correct
13 Correct 16 ms 724 KB Output is correct
14 Correct 22 ms 852 KB Output is correct
15 Correct 22 ms 812 KB Output is correct
16 Correct 32 ms 788 KB Output is correct
17 Correct 25 ms 736 KB Output is correct
18 Correct 29 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3020 ms 82632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3029 ms 10436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 10 ms 468 KB Output is correct
12 Correct 14 ms 596 KB Output is correct
13 Correct 16 ms 724 KB Output is correct
14 Correct 22 ms 852 KB Output is correct
15 Correct 22 ms 812 KB Output is correct
16 Correct 32 ms 788 KB Output is correct
17 Correct 25 ms 736 KB Output is correct
18 Correct 29 ms 724 KB Output is correct
19 Execution timed out 3026 ms 23356 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 10 ms 468 KB Output is correct
12 Correct 14 ms 596 KB Output is correct
13 Correct 16 ms 724 KB Output is correct
14 Correct 22 ms 852 KB Output is correct
15 Correct 22 ms 812 KB Output is correct
16 Correct 32 ms 788 KB Output is correct
17 Correct 25 ms 736 KB Output is correct
18 Correct 29 ms 724 KB Output is correct
19 Execution timed out 3020 ms 82632 KB Time limit exceeded
20 Halted 0 ms 0 KB -