Submission #9074864
Source Code Expand
Copy
#include <bits/stdc++.h> using namespace std; vector <long long int> v; vector <double> vd; vector <char> vc; vector <string> vs; map <string,int> sm; map <int,int> mp; map <char,int>cm; set <int> st; #define For(n) for(int i=0; i<n; i++) //#define sort(v) sort(v.begin(),v.end()); #define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i];} //int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;} long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);} long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);} //int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;} //long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);} //int cnt =0; void SieveOfEratosthenes(int n=20000000) { // v.push_back(1); // bool prime[n+1]; // memset(prime, true, sizeof(prime)); vector <bool>prime(n+1,true); for (int p=2; p*p<=n; p++) { if (prime[p] == true) { for (int i=p*p; i<=n; i += p) prime[i] = false; } } for (int p=2; p<=n; p++) if (prime[p]) mp[p]++; } //int mod(string num, int a) //{ // // Initialize result // int res = 0; // // // One by one process all digits of 'num' // for (int i = 0; i < num.length(); i++) // res = (res*10 + (int)num[i] - '0') %a; // // return res; //} //vector <int> arr(100,-1); // //int fib(int n) //{ // if(n<=1)return 1; // // if(arr[n]==-1) // { // arr[n] = fib(n-1)+fib(n-2); // } // //else return arr[n]; // // return arr[n]; //} //int arr[1050][1050]; // //int mx=0; //int LCS(string s, string p) //{ // for(int i=1; i<=s.size(); i++) // { // for(int j=1; j<=p.size(); j++) // { // // if(s[i-1]==p[j-1]) // arr[i][j]=1+arr[i-1][j-1]; // else // arr[i][j]=max(arr[i-1][j],arr[i][j-1]); // // } // } // return arr[s.size()][p.size()]; //} // // //void primeFactors(long double n) //{ // // while(fmod(n, 2)==0) // { // x++; // n /= 2; // } // h+=x; // x=0; // // for(int i=3; i<=sqrt(n); i+=2) // { // // while(fmod(n, i)==0) // { // x++; // n /= i; // } // h+=x; // x=0; // // } // // if(n>2){ // h++; // } // //} int main() { int a,b=0,c=1,n; cin >> n ; for(int i=0; i<n; i++) { cin >> a; v.push_back(a); } for(int i=0; i<n; i++) { if(v[i]==c) { c++; } else b++; } if(b==n)cout << -1 << endl; else cout << b << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Brick Break |
User | shubho |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 3038 Byte |
Status | AC |
Exec Time | 64 ms |
Memory | 2420 KB |
Judge Result
Set Name | All | Sample | ||||
---|---|---|---|---|---|---|
Score / Max Score | 400 / 400 | 0 / 0 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
All | sample_01, sample_02, sample_03, sample_04, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_2, testcase_20, testcase_21, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9 |
Sample | sample_01, sample_02, sample_03, sample_04 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01 | AC | 1 ms | 256 KB |
sample_02 | AC | 1 ms | 256 KB |
sample_03 | AC | 1 ms | 256 KB |
sample_04 | AC | 1 ms | 256 KB |
testcase_0 | AC | 23 ms | 1400 KB |
testcase_1 | AC | 47 ms | 2420 KB |
testcase_10 | AC | 63 ms | 2420 KB |
testcase_11 | AC | 60 ms | 2420 KB |
testcase_12 | AC | 60 ms | 2420 KB |
testcase_13 | AC | 60 ms | 2420 KB |
testcase_14 | AC | 60 ms | 2420 KB |
testcase_15 | AC | 60 ms | 2420 KB |
testcase_16 | AC | 60 ms | 2420 KB |
testcase_17 | AC | 60 ms | 2420 KB |
testcase_18 | AC | 60 ms | 2420 KB |
testcase_19 | AC | 60 ms | 2420 KB |
testcase_2 | AC | 60 ms | 2420 KB |
testcase_20 | AC | 60 ms | 2420 KB |
testcase_21 | AC | 61 ms | 2420 KB |
testcase_3 | AC | 47 ms | 2420 KB |
testcase_4 | AC | 43 ms | 2420 KB |
testcase_5 | AC | 64 ms | 2420 KB |
testcase_6 | AC | 42 ms | 2420 KB |
testcase_7 | AC | 8 ms | 640 KB |
testcase_8 | AC | 60 ms | 2420 KB |
testcase_9 | AC | 33 ms | 2420 KB |