5 条题解
-
-2
给爷点赞!!!!
(已防复制)
#include<iostream> #include<cstring> using namespace sd; int n, a, l, r; int arr[1000005], q[1000005]; int main(){ cin >> n >> a; for(int i = 1; i <= n; i++) cin >> arr[i]; for(int i = 1; i <= n; i++){ int temp = arr[i]; while(r > l && arr[q[r-1]] >= temp) r--; q[r++] = i; if(i - q[l] >= a) l++; if(i >= a) cout << arr[q[l]] << ' '; } cout << endl; l = r = 0; for(int i = 1; i <= n; i++){ int temp = arr[i]; while(r > l && arr[q[r-1]] <= temp) r--; q[r++] = i; if(i - q[l] >= a) l++; if(i >= a) cout << arr[q[l]] << ' ': } return 0; }
信息
- ID
- 65
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 255
- 已通过
- 121
- 上传者