Submission #3456622
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), mx(n + 1, 1);
for(int i = 0; i < n; i++){
int tmp; cin >> tmp;
a[tmp] = i;
}
mx[2] = 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());
if(a[n] == n - 1)
res = max(res, mx[n - 1] + 1);
if(a[1] == 0){
int tres = 1;
for(int i = 3; i < n; i++)
if(mx[i] == mx[i - 1] + 1)
tres = mx[i];
else break;
res = max(res, tres + 1);
}
cout << n - res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Fairness |
| User | NourElRashidy |
| Language | C++14 (GCC 5.4.1) |
| Score | 0 |
| Code Size | 676 Byte |
| Status | RE |
| Exec Time | 2039 ms |
| Memory | 966260 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
| 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, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | RE | 1415 ms | -1387652 KiB |
| 02.txt | RE | 1003 ms | -1589888 KiB |
| 03.txt | RE | 2039 ms | -761868 KiB |
| 04.txt | RE | 502 ms | 966260 KiB |
| 05.txt | WA | 3 ms | 384 KiB |
| 06.txt | RE | 98 ms | 384 KiB |
| 07.txt | WA | 1 ms | 256 KiB |
| 08.txt | WA | 1 ms | 256 KiB |
| 09.txt | RE | 97 ms | 256 KiB |
| s1.txt | WA | 1 ms | 256 KiB |
| s2.txt | WA | 1 ms | 256 KiB |
| s3.txt | RE | 100 ms | 256 KiB |