Submission #442922

#TimeUsernameProblemLanguageResultExecution timeMemory
442922prvocisloMatching (CEOI11_mat)C++17
63 / 100
2098 ms5388 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...