/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Wrong Answer 4ms 388.0 KiB
#3 Wrong Answer 4ms 320.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-11-11 03:16:07
Judged By
Score
5
Total Time
4ms
Peak Memory
536.0 KiB