Submission #1140981

#TimeUsernameProblemLanguageResultExecution timeMemory
1140981dpsaveslivesSequence (BOI14_sequence)C++20
34 / 100
3 ms584 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> arr; int K;
bool good(int x){
    for(int i = 0;i<K;++i){
        int cur = x; bool ok = false;
        while(cur > 0){
            if(cur%10 == arr[i]){
                ok = true;
                break;
            }
            cur /= 10;
        }
        if(!ok) return false;
        ++x;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> K;
    arr.resize(K);
    bool same = true;
    for(int i = 0;i<K;++i){
        cin >> arr[i];
        if(i != 0){
            if(arr[i] != arr[i-1]){
                same = false;
            }
        }
    }
    if(!same){
        for(int i = 1;i<=1000;++i){
            if(good(i)){
                cout << i << "\n";
                return 0;
            }
        }
    }
    if(arr[0] == 0){
        int x = 1, ans = 10;
        while(x < K){
            x *= 10;
            ++x;
            ans *= 10;
        }
        cout << ans << "\n";
        return 0;
    }
    else if(arr[0] == 9){
        int x = 1, ans = 8;
        while(x < K){
            x *= 10;
            ++x;
            ans *= 10;
            ans += 8;
        }
        ++ans;
        cout << ans << "\n";
        return 0;
    }
    int x = 1;
    while(K > x){
        x *= 10;
    }
    x *= arr[0];
    cout << x << "\n";
    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...