#include "bubblesort2.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <stack>
typedef long long llong;
const int MAXN = 500000 + 10;
const int INF = 1e9;
int n, q;
int a[MAXN];
int dp[MAXN];
std::vector <int> countScans(std::vector <int> A, std::vector <int> X, std::vector <int> V)
{
n = A.size();
q = X.size();
for (int i = 1 ; i <= n ; ++i)
{
a[i] = A[i - 1];
}
std::vector <int> answer(q);
for (int query = 0 ; query < q ; ++query)
{
a[X[query] + 1] = V[query];
std::stack <int> st;
for (int i = 1 ; i <= n ; ++i)
{
while (st.size() && a[st.top()] <= a[i])
{
st.pop();
}
st.push(i);
answer[query] = std::max(answer[query], (int)st.size() - 1);
}
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
767 ms |
2724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |