Submission #4020816


Source Code Expand

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e7))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((int)(5e5+2))
#define N ((int)(2e5 + 2))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int lu;

typedef tree < int ,  null_type ,  less < int > ,  rb_tree_tag ,  tree_order_statistics_node_update > o_set;

struct info{
    int v, i;
}a[N];

bool cmp(info a, info b)
{
    return a.v<b.v;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i<n; i++){
        scanf("%d",&a[i].v);
        a[i].i = i;
    }
    sort(a,a+n,cmp);
    int ans = n-1;
    a[0].v = 1;
    for(int i = 1; i<n; i++){
        a[i].v = 1;
        if(a[i-1].i<a[i].i) a[i].v = a[i-1].v+1;
        ans = min(ans,n-a[i].v);
    }
    printf("%d\n",ans);
    return 0;
}

Submission Info

Submission Time
Task B - Backfront
User tbs_sajal
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1128 Byte
Status AC
Exec Time 41 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
./Main.cpp:42:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i].v);
                            ^

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 41 ms 1792 KB
02.txt AC 41 ms 1792 KB
03.txt AC 41 ms 1792 KB
04.txt AC 41 ms 1792 KB
05.txt AC 41 ms 1792 KB
06.txt AC 41 ms 1792 KB
07.txt AC 31 ms 1792 KB
08.txt AC 31 ms 1792 KB
09.txt AC 28 ms 1792 KB
10.txt AC 28 ms 1792 KB
11.txt AC 40 ms 1792 KB
12.txt AC 38 ms 1792 KB
13.txt AC 40 ms 1792 KB
14.txt AC 40 ms 1792 KB
15.txt AC 41 ms 1792 KB
16.txt AC 41 ms 1792 KB
17.txt AC 41 ms 1792 KB
18.txt AC 41 ms 1792 KB
19.txt AC 31 ms 1792 KB
20.txt AC 31 ms 1792 KB
21.txt AC 39 ms 1792 KB
22.txt AC 39 ms 1792 KB
23.txt AC 1 ms 256 KB
24.txt AC 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