/ WOJ /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 成绩取消 0ms 0 Bytes

代码

#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

void Main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &x: a) {
    cin >> x;
  }
  deque<int> dq;
  for (int i = 0; i < n; ++i) {
    while (dq.size() && a[dq.back()] >= a[i]) {
      dq.pop_back();
    }
    dq.push_back(i);
    if (i - dq[0] == k) {
      dq.pop_front();
    }
    if (i + 1 >= k) {
      cout << a[dq[0]] << " ";
    }
  }
  cout << endl;
  dq.clear();
  for (int i = 0; i < n; ++i) {
    while (dq.size() && a[dq.back()] <= a[i]) {
      dq.pop_back();
    }
    dq.push_back(i);
    if (i - dq[0] == k) {
      dq.pop_front();
    }
    if (i + 1 >= k) {
      cout << a[dq[0]] << " ";
    }
  }
  cout << endl;
}

// #define __CP_MULTI_TEST_CASES

signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t = 1;
#ifdef __CP_MULTI_TEST_CASES
  cin >> t;
#endif
  while (t--) {
    Main();
  }
  return 0;
}

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2025-06-21 10:39:37
评测时间
2025-06-21 10:39:50
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes