Submission #3571411


Source Code Expand

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n;
	cin >> n;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	vector<bool> flg(n, false);
	set<ll> s;
	REPC(x, v) {
		if (x == 1) {
			s.emplace(0);
		} else if (!flg[x - 2]) {
			s.emplace(x - 1);
		}
		flg[x - 1] = true;
	}

	ll max = 0;
	ll tmp = 0;
	REPC(x, s) {
		max = std::max(max, x - tmp);
		tmp = x;
	}
	cout << n - max << endl;
}

Submission Info

Submission Time
Task B - Backfront
User cutmdo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2220 Byte
Status WA
Exec Time 116 ms
Memory 11264 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 24
WA × 4
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 93 ms 6528 KB
02.txt AC 93 ms 6528 KB
03.txt AC 94 ms 6528 KB
04.txt AC 93 ms 6528 KB
05.txt AC 101 ms 6528 KB
06.txt AC 94 ms 6528 KB
07.txt WA 59 ms 1792 KB
08.txt WA 59 ms 1792 KB
09.txt AC 116 ms 11264 KB
10.txt AC 115 ms 11264 KB
11.txt AC 60 ms 1792 KB
12.txt AC 59 ms 1792 KB
13.txt AC 59 ms 1792 KB
14.txt AC 59 ms 1792 KB
15.txt AC 59 ms 1792 KB
16.txt AC 62 ms 2048 KB
17.txt AC 81 ms 4992 KB
18.txt AC 81 ms 4992 KB
19.txt AC 59 ms 1792 KB
20.txt AC 59 ms 1792 KB
21.txt AC 85 ms 5888 KB
22.txt AC 85 ms 5888 KB
23.txt WA 1 ms 256 KB
24.txt WA 1 ms 256 KB
25.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB