Submission #3456936
Source Code Expand
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ios::sync_with_stdio(false);
// srand(time(NULL));
int n; cin >> n;
vector<int>a(n + 1), in(n), mx(n + 1, 1);
for(int i = 0; i < n; i++){
int tmp; cin >> tmp;
a[tmp] = i;
in[i] = tmp;
}
mx[1] = 1;
for(int i = 2; i <= n; i++)
if(a[i] > a[i - 1])
mx[i] = mx[i - 1] + 1;
int res = *max_element(mx.begin(), mx.end());
cout << n - res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Backfront |
| User | NourElRashidy |
| Language | C++14 (GCC 5.4.1) |
| Score | 500 |
| Code Size | 479 Byte |
| Status | AC |
| Exec Time | 22 ms |
| Memory | 2560 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| 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 | 21 ms | 2560 KiB |
| 02.txt | AC | 21 ms | 2560 KiB |
| 03.txt | AC | 21 ms | 2560 KiB |
| 04.txt | AC | 22 ms | 2560 KiB |
| 05.txt | AC | 22 ms | 2560 KiB |
| 06.txt | AC | 21 ms | 2560 KiB |
| 07.txt | AC | 19 ms | 2560 KiB |
| 08.txt | AC | 19 ms | 2560 KiB |
| 09.txt | AC | 19 ms | 2560 KiB |
| 10.txt | AC | 19 ms | 2560 KiB |
| 11.txt | AC | 20 ms | 2560 KiB |
| 12.txt | AC | 20 ms | 2560 KiB |
| 13.txt | AC | 20 ms | 2560 KiB |
| 14.txt | AC | 20 ms | 2560 KiB |
| 15.txt | AC | 20 ms | 2560 KiB |
| 16.txt | AC | 21 ms | 2560 KiB |
| 17.txt | AC | 21 ms | 2560 KiB |
| 18.txt | AC | 21 ms | 2560 KiB |
| 19.txt | AC | 19 ms | 2560 KiB |
| 20.txt | AC | 19 ms | 2560 KiB |
| 21.txt | AC | 21 ms | 2560 KiB |
| 22.txt | AC | 21 ms | 2560 KiB |
| 23.txt | AC | 1 ms | 256 KiB |
| 24.txt | AC | 1 ms | 256 KiB |
| 25.txt | AC | 1 ms | 256 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 1 ms | 256 KiB |