/** MIT License Copyright (c) 2018-2019(!) Vasilyev Daniil **/
#include <bits/stdc++.h>
using namespace std;
template<typename T> using v = vector<T>;
//#define int long long
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-9;
#if 0 //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt" : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg) ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg arg,Args... args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
//code starts here
const int M = 100000;
char decomp[M][10];
void decompose(int d) {
if (d == 0) {decomp[d][0] = 1; return;}
int p = d;
while (p) {
decomp[d][p % 10] = 1;
p /= 10;
}
}
void run() {
int k;
get k;
int d[k];
rep(i, 0, k)
get d[i];
rep(i, 0, M)
decompose(i);
long long ans = inf;
rep(i, 1, 9001) {
char need[10];
memset(need, 0, sizeof need);
rep(j, 0, k)
if (!decomp[i + j][d[j]])
need[d[j]] = 1;
long long pans = i;
long long num = 0;
rep(j, 1, 10)
if (need[j]) {
num = num * 10 + j;
if (need[0]) {
need[0] = 0;
num *= 10;
}
}
if (need[0])
num = 10;
pans += num * 10000;
ans = min(ans, pans);
}
put ans;
}
signed main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run(); return 0;}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1272 KB |
Output is correct |
2 |
Correct |
17 ms |
1272 KB |
Output is correct |
3 |
Correct |
6 ms |
1144 KB |
Output is correct |
4 |
Correct |
7 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1272 KB |
Output is correct |
6 |
Correct |
4 ms |
1272 KB |
Output is correct |
7 |
Correct |
4 ms |
1276 KB |
Output is correct |
8 |
Correct |
14 ms |
1272 KB |
Output is correct |
9 |
Correct |
3 ms |
1272 KB |
Output is correct |
10 |
Correct |
35 ms |
1272 KB |
Output is correct |
11 |
Correct |
33 ms |
1272 KB |
Output is correct |
12 |
Correct |
7 ms |
1272 KB |
Output is correct |
13 |
Correct |
9 ms |
1272 KB |
Output is correct |
14 |
Correct |
44 ms |
1272 KB |
Output is correct |
15 |
Correct |
44 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1276 KB |
Output is correct |
2 |
Correct |
17 ms |
1272 KB |
Output is correct |
3 |
Correct |
7 ms |
1272 KB |
Output is correct |
4 |
Correct |
7 ms |
1272 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
3 ms |
1272 KB |
Output is correct |
7 |
Correct |
15 ms |
1272 KB |
Output is correct |
8 |
Correct |
5 ms |
1272 KB |
Output is correct |
9 |
Correct |
15 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
1272 KB |
Output is correct |
11 |
Correct |
25 ms |
1272 KB |
Output is correct |
12 |
Correct |
34 ms |
1272 KB |
Output is correct |
13 |
Correct |
33 ms |
1272 KB |
Output is correct |
14 |
Correct |
8 ms |
1272 KB |
Output is correct |
15 |
Correct |
9 ms |
1272 KB |
Output is correct |
16 |
Correct |
42 ms |
1400 KB |
Output is correct |
17 |
Correct |
42 ms |
1360 KB |
Output is correct |
18 |
Correct |
9 ms |
1272 KB |
Output is correct |
19 |
Correct |
17 ms |
1276 KB |
Output is correct |
20 |
Correct |
57 ms |
1272 KB |
Output is correct |
21 |
Correct |
14 ms |
1272 KB |
Output is correct |
22 |
Correct |
44 ms |
1400 KB |
Output is correct |
23 |
Correct |
45 ms |
1272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1272 KB |
Output is correct |
2 |
Incorrect |
145 ms |
1420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1272 KB |
Output is correct |
2 |
Correct |
18 ms |
1272 KB |
Output is correct |
3 |
Correct |
7 ms |
1272 KB |
Output is correct |
4 |
Correct |
7 ms |
1272 KB |
Output is correct |
5 |
Execution timed out |
1079 ms |
1528 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |