Submission #117832


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <list>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define EPS 1e-9
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

struct FenwickTree {
	typedef ll T;
	vector<T> v;
	FenwickTree(int n): v(n, 0) {}
	void add(int i, T x) {
		for(; i < v.size(); i |= i+1) v[i] += x;
	}
	T sum(int i) {	//[0, i)
		T r = 0;
		for(-- i; i >= 0; i = (i & (i+1)) - 1) r += v[i];
		return r;
	}
	T sum(int left, int right) {	//[left, right)
		return sum(right) - sum(left);
	}
};


ll a[50000];
int main() {
	int n, k;
	while(cin >> n >> k, n != -1) {
		rep(i, n) cin >> a[i];
		map<ll,int> ord;
		vector<ll> v;
		rep(i, n) ord[a[i]] = -1;
		each(i, ord) i->second = v.size(), v.pb(i->first);
		int x = v.size();
		FenwickTree ft(x);
		bool ok = true;
		rep(i, n) {
			ok &= ft.sum(ord[a[i]]+1, x) == 0;
			int j = i - k;
			if(j >= 0) ft.add(ord[a[j]], 1);
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task J - ALPHAのならび
User anta
Language C++11 (GCC 4.8.1)
Score 100
Code Size 2053 Byte
Status AC
Exec Time 565 ms
Memory 5276 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 17
Set Name Test Cases
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
Case Name Status Exec Time Memory
00-sample AC 21 ms 800 KB
01-maximum AC 504 ms 5220 KB
02-longlong-01 AC 465 ms 1188 KB
02-longlong-02 AC 461 ms 1180 KB
03-kborder01 AC 22 ms 736 KB
03-kborder02 AC 21 ms 800 KB
03-kborder03 AC 22 ms 920 KB
50-random01 AC 466 ms 4772 KB
50-random02 AC 436 ms 4940 KB
50-random03 AC 483 ms 5040 KB
50-random04 AC 565 ms 5148 KB
50-random05 AC 484 ms 4904 KB
50-random06 AC 477 ms 5112 KB
50-random07 AC 515 ms 5272 KB
50-random08 AC 543 ms 5276 KB
50-random09 AC 358 ms 5172 KB
50-random10 AC 406 ms 4640 KB