/*
ID: agageld1
LANG: C++17
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 4000005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, t, T, a[N], p, r = 1;
string s, g, h;
int main () {
//freopen("txt.in","r",stdin);
//freopen("txt.out","w",stdout);
ios::sync_with_stdio(0);cin.tie(0);
cin >> n;
bool w = 0;
for(int i = 1; i <= n; i++) {
cin >> a[i];
if(a[1] != a[i]) w = 1;
}
if(!w) p = a[1];
for(int i = 1;; i++) {
if(!w) {
i = p;
p *= 10;
}
bool tr = 0;
for(int j = i; j <= i + n - 1; j++) {
t = j;
while(t != 0 && (t % 10) != a[j - i + 1]) {
t /= 10;
}
if(t == 0 || t % 10 != a[j - i + 1]) {
tr = 1;
break;
}
}
if(!tr) {
cout << i << '\n';
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |