Submission #3228874


Source Code Expand

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e30
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, L, R, K, X,Y, A, B, C, Z;
ll ans;
string S;
ll a[200];
ll x[100000000];
ll y[100000000];
ll nowcost = 1;
ll twopow[202020];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll dp[1000001];
ll p[1000000];
ll pos[1000000];

int main() {
	cin>>N;
	rep(i,1,N+1){
		cin>>p[i];
	}
	rep(i,1,N+1){
		if(pos[p[i]-1]==0){
			pos[p[i]]=i;
		}else{
			pos[p[i]]=pos[p[i]-1];
		}
	}
	rep(i,1,N+1){
		dp[pos[i]]++;
		ans = max(ans,dp[pos[i]]);
	}
	cout<<N-ans<<endl;
	return 0;
}

Submission Info

Submission Time
Task B - Backfront
User Hide1204
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1434 Byte
Status AC
Exec Time 64 ms
Memory 9984 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 28
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 61 ms 9984 KB
02.txt AC 61 ms 9984 KB
03.txt AC 61 ms 9984 KB
04.txt AC 64 ms 9984 KB
05.txt AC 61 ms 9984 KB
06.txt AC 61 ms 9984 KB
07.txt AC 61 ms 7936 KB
08.txt AC 61 ms 7936 KB
09.txt AC 61 ms 9984 KB
10.txt AC 61 ms 9984 KB
11.txt AC 61 ms 7936 KB
12.txt AC 61 ms 7936 KB
13.txt AC 61 ms 7936 KB
14.txt AC 60 ms 7936 KB
15.txt AC 61 ms 7936 KB
16.txt AC 61 ms 7936 KB
17.txt AC 62 ms 9984 KB
18.txt AC 61 ms 9984 KB
19.txt AC 61 ms 9984 KB
20.txt AC 61 ms 9984 KB
21.txt AC 61 ms 9984 KB
22.txt AC 62 ms 9984 KB
23.txt AC 2 ms 4352 KB
24.txt AC 2 ms 4352 KB
25.txt AC 2 ms 4352 KB
s1.txt AC 2 ms 4352 KB
s2.txt AC 2 ms 4352 KB
s3.txt AC 2 ms 4352 KB