提出 #117552


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
const int inf = (1<<28);

int main() {
  int n, k;
  while(cin >> n >> k, !(n==-1 && k==-1)) {
    vector<ull> a(n);
    rep(i, n) cin >> a[i];
    
    if(n == 0) { cout << "Yes" << endl; continue; }
    
    priority_queue<pair<ull, int>, vector<pair<ull, int> >, greater<pair<ull, int> > > rest;
    rep(i, n) rest.push(mp(a[i], i));
    
    bool yes = true;
    
    rep(i, n) {
      while(rest.top().first < a[i]) {
        pair<ull, int> x = rest.top(); rest.pop();
        if(x.second > i+k) yes = false;
      }
    }
    
    cout << (yes ? "Yes" : "No") << endl;
  }
}

提出情報

提出日時
問題 J - ALPHAのならび
ユーザ suminos
言語 C++ (G++ 4.6.4)
得点 100
コード長 953 Byte
結果 AC
実行時間 480 ms
メモリ 3120 KiB

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 17
セット名 テストケース
All 00-sample, 01-maximum, 02-longlong-01, 02-longlong-02, 03-kborder01, 03-kborder02, 03-kborder03, 50-random01, 50-random02, 50-random03, 50-random04, 50-random05, 50-random06, 50-random07, 50-random08, 50-random09, 50-random10
ケース名 結果 実行時間 メモリ
00-sample AC 22 ms 796 KiB
01-maximum AC 263 ms 2996 KiB
02-longlong-01 AC 480 ms 3004 KiB
02-longlong-02 AC 480 ms 3120 KiB
03-kborder01 AC 24 ms 928 KiB
03-kborder02 AC 21 ms 804 KiB
03-kborder03 AC 21 ms 804 KiB
50-random01 AC 361 ms 2808 KiB
50-random02 AC 336 ms 2916 KiB
50-random03 AC 359 ms 2936 KiB
50-random04 AC 439 ms 2916 KiB
50-random05 AC 379 ms 2832 KiB
50-random06 AC 398 ms 2864 KiB
50-random07 AC 401 ms 2868 KiB
50-random08 AC 423 ms 2892 KiB
50-random09 AC 289 ms 2688 KiB
50-random10 AC 326 ms 2780 KiB