Submission #95966

# Submission time Handle Problem Language Result Execution time Memory
95966 2019-02-04T18:54:43 Z SpeedOfMagic Sequence (BOI14_sequence) C++17
42 / 100
1000 ms 1656 KB
/** 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);

    int ans = inf;
    rep(i, 1, 99001) {
        char need[10];
        memset(need, 0, sizeof need);
        rep(j, 0, k)
            if (!decomp[i + j][d[j]])
                need[d[j]] = 1;
        int pans = i;
        int 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 * 100000;
        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;}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1272 KB Output is correct
2 Correct 175 ms 1392 KB Output is correct
3 Correct 41 ms 1244 KB Output is correct
4 Correct 43 ms 1272 KB Output is correct
5 Correct 6 ms 1352 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 15 ms 1272 KB Output is correct
8 Correct 91 ms 1320 KB Output is correct
9 Correct 5 ms 1272 KB Output is correct
10 Correct 409 ms 1372 KB Output is correct
11 Correct 369 ms 1400 KB Output is correct
12 Correct 43 ms 1400 KB Output is correct
13 Correct 71 ms 1272 KB Output is correct
14 Correct 481 ms 1272 KB Output is correct
15 Correct 491 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1272 KB Output is correct
2 Correct 175 ms 1276 KB Output is correct
3 Correct 41 ms 1272 KB Output is correct
4 Correct 43 ms 1272 KB Output is correct
5 Correct 6 ms 1272 KB Output is correct
6 Correct 7 ms 1272 KB Output is correct
7 Correct 89 ms 1272 KB Output is correct
8 Correct 17 ms 1272 KB Output is correct
9 Correct 94 ms 1400 KB Output is correct
10 Correct 5 ms 1272 KB Output is correct
11 Correct 246 ms 1312 KB Output is correct
12 Correct 387 ms 1400 KB Output is correct
13 Correct 371 ms 1272 KB Output is correct
14 Correct 43 ms 1276 KB Output is correct
15 Correct 70 ms 1272 KB Output is correct
16 Correct 539 ms 1368 KB Output is correct
17 Correct 494 ms 1400 KB Output is correct
18 Correct 70 ms 1272 KB Output is correct
19 Correct 147 ms 1272 KB Output is correct
20 Correct 508 ms 1368 KB Output is correct
21 Correct 138 ms 1272 KB Output is correct
22 Correct 541 ms 1372 KB Output is correct
23 Correct 539 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1272 KB Output is correct
2 Execution timed out 1088 ms 1400 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1272 KB Output is correct
2 Correct 174 ms 1364 KB Output is correct
3 Correct 41 ms 1272 KB Output is correct
4 Correct 43 ms 1272 KB Output is correct
5 Execution timed out 1072 ms 1656 KB Time limit exceeded
6 Halted 0 ms 0 KB -