/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 6ms 624.0 KiB
#3 Accepted 5ms 532.0 KiB
#4 Accepted 4ms 616.0 KiB
#5 Accepted 5ms 532.0 KiB
#6 Accepted 10ms 616.0 KiB
#7 Accepted 11ms 624.0 KiB
#8 Accepted 5ms 576.0 KiB
#9 Accepted 5ms 532.0 KiB
#10 Accepted 12ms 532.0 KiB
#11 Accepted 5ms 532.0 KiB
#12 Accepted 8ms 580.0 KiB
#13 Accepted 10ms 532.0 KiB
#14 Accepted 10ms 532.0 KiB
#15 Accepted 12ms 432.0 KiB

Code

//! In The Name Of Allah

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define pb push_back
#define pob pop_back
#define make M
#define F first
#define S second
#define all(s) (s).begin(), (s).end()
#define rall(s) s.rbegin(), s.rend()
#define sz(x) (int)x.size()
#define mem(a, b) memset(a, b, sizeof(a))
#define log2(x) 31 - __builtin_clz(x)
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define TxtIO                         \
    freopen("sample.in", "r", stdin); \
    freopen("sample.out", "w", stdout);
#define Fokinnir_moto_kaj_koris_na \
    ios_base::sync_with_stdio(0);  \
    cin.tie(0);                    \
    cout.tie(0);
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define PI acos(-1)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef double dl;

const ll Goriber_INF = 1e18;
const ll Mod = 1e9 + 7;
const ll N = 2e5 + 12;
int n,k;
string s[1005];
bool ok(string a,string b)
{
    if(sz(a) < sz(b))return 1;
    if(sz(a) > sz(b))return 0;
    for(int i = 0; i < sz(a); i++){
        if(a[i] < b[i])return 1;
        if(a[i] > b[i])return 0;
    }
    return 1;
}
string f(int i)
{
    string la = "";
    for(int j = 0; j <= k; j++){
        la += s[i+j];
    }
    return la;
}
void Goriber_solve()
{
    cin >> n >> k;
    int la = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        s[i] = to_string(x);
        la = max(la,x);
    }
    if(k == 0){
        cout << la << endl;
        return;
    }
    string ans = s[0];
    for(int i = 0; i + k < n; i++){
        string la = f(i);
        bool ff = ok(ans,la);
        if(ff)ans = la;
    }
    cout << ans << endl;

}
signed main()
{

    Fokinnir_moto_kaj_koris_na 
    int _ = 1,h = 0;
    cin >> _;
    while (_--)
    {
        //cout<<"Case "<<++h<<": ";
        Goriber_solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Contest
Bangladesh 2.0
Language
C++17 (G++ 13.2.0)
Submit At
2024-08-16 17:32:19
Judged At
2024-08-16 17:32:19
Judged By
Score
100
Total Time
12ms
Peak Memory
624.0 KiB