/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 4ms 532.0 KiB
#3 Wrong Answer 4ms 348.0 KiB
#4 Time Exceeded ≥2059ms ≥324.0 KiB
#5 Time Exceeded ≥2093ms ≥324.0 KiB
#6 Time Exceeded ≥2085ms ≥324.0 KiB
#7 Time Exceeded ≥2074ms ≥532.0 KiB
#8 Wrong Answer 2ms 764.0 KiB
#9 Time Exceeded ≥2084ms ≥396.0 KiB
#10 Time Exceeded ≥2078ms ≥532.0 KiB
#11 Wrong Answer 2ms 320.0 KiB
#12 Wrong Answer 2ms 380.0 KiB
#13 Time Exceeded ≥2092ms ≥324.0 KiB
#14 Time Exceeded ≥2071ms ≥320.0 KiB
#15 Time Exceeded ≥2076ms ≥324.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> PII;
const ll mx = 3e5+10;

ll Concat(ll a, ll b) {
    ll Mul = 1;
    while(Mul <=b) Mul*=10;
    return a*Mul + b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin>>t;
    while(t--) {
        ll n, k;
        cin >> n >> k;
        vector<ll> Vec(n);
        for(int i=0; i<n; i++) cin >> Vec[i];
        while(k>0 and n>1) {
            ll Max = LONG_MIN;
            int Id = -1;
            for(int i=0; i<n-1; i++) {
                ll Pair = Concat(Vec[i],Vec[i+1]);
                if(Pair > Max) {
                    Max = Pair;
                    Id = i;
                }
            }
            if(Id != -1) {
                Vec[Id] = Max;
                Vec.erase(Vec.begin() + Id + 1);
                n--;
            }
            k--;
        }

        cout<<*max_element(Vec.begin(), Vec.end())<<endl;
    }
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:06:03
Judged At
2024-10-03 13:28:40
Judged By
Score
5
Total Time
≥2093ms
Peak Memory
≥764.0 KiB