// in the name of God
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define mk make_pair
#define ppb pop_back
#define endl '\n'
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define file() freopen("input.txt", "r", stdin);
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7, maxn = 1e7 + 10, sq = 3163, inf = 1e18 + 10, lg = 25, pp = 4447, modd = 1e9 + 9;
int n;
string a;
bool b[maxn][10];
signed main(){
fast();//file();
for(int i = 0; i < maxn; ++i){
string s = to_string(i);
for(int j = 0; j < s.size(); ++j) b[i][s[j] - '0'] = true;
}
cin >> n;
for(int i = 0; i < n; ++i) {int x; cin >> x; a += ((char) x + '0');}
for(int i = 1; i <= maxn; ++i){
bool bol = true;
for(int j = 0; j < n; ++j){
if(!b[i + j][a[j] - '0']) {bol = false; break;}
}
if(bol){
cout << i;
return 0;
}
}
cout << -1 << endl;
}
// Happiness can be found even in the darkest of times,
// if one only remembers to turn on the light.
Compilation message
sequence.cpp: In function 'int main()':
sequence.cpp:29:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int j = 0; j < s.size(); ++j) b[i][s[j] - '0'] = true;
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
170 ms |
98284 KB |
Output is correct |
2 |
Correct |
151 ms |
98256 KB |
Output is correct |
3 |
Correct |
151 ms |
98132 KB |
Output is correct |
4 |
Correct |
170 ms |
98132 KB |
Output is correct |
5 |
Correct |
156 ms |
98252 KB |
Output is correct |
6 |
Correct |
159 ms |
98060 KB |
Output is correct |
7 |
Correct |
153 ms |
98188 KB |
Output is correct |
8 |
Correct |
152 ms |
98128 KB |
Output is correct |
9 |
Correct |
180 ms |
98092 KB |
Output is correct |
10 |
Correct |
152 ms |
98044 KB |
Output is correct |
11 |
Correct |
152 ms |
98256 KB |
Output is correct |
12 |
Correct |
168 ms |
98136 KB |
Output is correct |
13 |
Correct |
174 ms |
98200 KB |
Output is correct |
14 |
Correct |
155 ms |
98196 KB |
Output is correct |
15 |
Correct |
159 ms |
98252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
159 ms |
98200 KB |
Output is correct |
2 |
Correct |
165 ms |
98192 KB |
Output is correct |
3 |
Correct |
160 ms |
98132 KB |
Output is correct |
4 |
Correct |
156 ms |
98132 KB |
Output is correct |
5 |
Correct |
157 ms |
98140 KB |
Output is correct |
6 |
Correct |
160 ms |
98132 KB |
Output is correct |
7 |
Correct |
156 ms |
98188 KB |
Output is correct |
8 |
Correct |
157 ms |
98256 KB |
Output is correct |
9 |
Correct |
154 ms |
98200 KB |
Output is correct |
10 |
Correct |
157 ms |
98208 KB |
Output is correct |
11 |
Incorrect |
865 ms |
98288 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
153 ms |
98044 KB |
Output is correct |
2 |
Correct |
161 ms |
98160 KB |
Output is correct |
3 |
Correct |
573 ms |
98136 KB |
Output is correct |
4 |
Correct |
164 ms |
98416 KB |
Output is correct |
5 |
Correct |
623 ms |
98316 KB |
Output is correct |
6 |
Correct |
155 ms |
98080 KB |
Output is correct |
7 |
Correct |
287 ms |
98388 KB |
Output is correct |
8 |
Correct |
567 ms |
98436 KB |
Output is correct |
9 |
Correct |
411 ms |
98512 KB |
Output is correct |
10 |
Correct |
496 ms |
98644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
155 ms |
98084 KB |
Output is correct |
2 |
Correct |
156 ms |
98452 KB |
Output is correct |
3 |
Correct |
153 ms |
98132 KB |
Output is correct |
4 |
Correct |
151 ms |
98064 KB |
Output is correct |
5 |
Incorrect |
189 ms |
98640 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |