Submission #439932

# Submission time Handle Problem Language Result Execution time Memory
439932 2021-07-01T08:31:44 Z Andrei1998 Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
9000 ms 460 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;

int solve(const vector<int> &A) {
  const int N = A.size();
  vector<int> stk = {0};
  int best = 0;
  for (int i = 1; i < N; ++i) {
    if (A[i] > A[stk.back()]) {
      stk.push_back(i);
    } else if (A[i] < A[stk.back()]) {
      int st = 0, dr = (int)stk.size() - 2;
      while (st <= dr) {
        const int mid = (st + dr) / 2;
        if (A[i] < A[stk[mid]]) {
          dr = i - 1;
        } else {
          st = i + 1;
        }
      }
      best = max(best, i - stk[dr + 1]);
    }
  }
  return best;
}

vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) {
  int Q = X.size();
  vector<int> answer(Q);
  for (int j = 0; j < Q; j++) {
    A[X[j]] = V[j];
    answer[j] = solve(A);
  }
  return answer;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 9003 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9003 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9016 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9003 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -