이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int st[maxn], s[maxn], h[maxn], l = 0, r = 0;
void pridaj(int i)
{
while (r > l && h[st[r-1]] > h[i]) r--;
st[r++] = i;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> s[i], s[i]--;
for (int i = 0; i < m; i++) cin >> h[i];
vector<int> ans;
for (int i = 0; i < n; i++) pridaj(i);
for (int i = 0; i + n - 1 < m; i++)
{
if (i) pridaj(i + n - 1);
if (st[l] < i) l++;
if (st[l] != i + s[0]) continue;
bool ok = true;
for (int j = 1; j < n; j++)
{
//cout << i+s[j-1] << " " << i+s[j] << endl;
if (h[i+s[j-1]] > h[i+s[j]])
{
ok = false;
break;
}
}
if (ok) ans.push_back(i+1);
}
cout << ans.size() << "\n";
for (int i : ans) cout << i << " ";
cout << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |