Submission #95966

#TimeUsernameProblemLanguageResultExecution timeMemory
95966SpeedOfMagicSequence (BOI14_sequence)C++17
42 / 100
1088 ms1656 KiB
/** 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...