/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 5ms 2.996 MiB
#3 Accepted 4ms 2.629 MiB
#4 Accepted 4ms 2.562 MiB
#5 Accepted 3ms 2.566 MiB
#6 Accepted 4ms 2.742 MiB
#7 Accepted 4ms 2.566 MiB
#8 Accepted 2ms 580.0 KiB
#9 Accepted 2ms 532.0 KiB
#10 Accepted 3ms 2.52 MiB
#11 Accepted 2ms 324.0 KiB
#12 Accepted 2ms 792.0 KiB
#13 Accepted 2ms 832.0 KiB
#14 Accepted 2ms 640.0 KiB
#15 Accepted 4ms 2.613 MiB

Code

/*
**************************************************************
*Bis'Millah Hir Rah'Manir Rahim == start with the name of \n *
*                    ALLAH Subhana Tayala                    *
*                Author: Md. Mahabubar Rahman                *
*               CSE,RPI && Rangpur, Bangladesh               *
**************************************************************
*/
#include <bits/stdc++.h>
using namespace std;
#define Allhamdulillah 0
#define pb(x) push_back(x)
#define pp() pop_back()
#define ll long long int
#define foi(i, s, e) for (int i = s; i < e; i++)
#define cn(x) cin >> x
#define endl '\n'
#define Endl '\n'
#define nl cout << '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"

int sss(int n){
    string s=to_string(n);
    return s.size();
}
void solve()
{
    int n,k;cin>>n>>k;int arr[n];for(auto &c:arr)cin>>c;
    vector<string>ans;  
    string s="",s2;
    for(int i=0;i<=k;i++)s+=to_string(arr[i]);
    int start=1,j=k+1;
    ans.push_back(s);
    while(j<n){
        s+=to_string(arr[j]);
        int dlt=sss(arr[start-1]),tt=s.size();
        s2=s.substr(dlt,tt-dlt);
        ans.push_back(s2);
        s=s2;
        start++;
        j++;
    }
    sort(ans.begin(),ans.end(),[](auto &a,auto &b){
        if(a.size()==b.size()){
            for(int i=0;i<a.size();i++){
                if(a[i]==b[i])continue;
                if(a[i]>b[i])return a>b;
                else b>a;
            }
        }
        else return a.size()>b.size();
    });
    cout<<ans[0]<<endl;
}
/*mdmahabub55*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    cin >> t;
    // t = 1;

    while (t--)
    {
        solve();
    }
    return Allhamdulillah;
}

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:19:54
Judged At
2024-10-03 13:27:31
Judged By
Score
100
Total Time
5ms
Peak Memory
2.996 MiB