/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

void solve()
{
    int n,k; cin >> n >> k;
    string arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    string ans = "0";
    for (int i = 0; i < n-k; i++) {
        string s = "";
        for (int j = i; j <= i+k; j++) {
            s += arr[j];
        }
        //cout << s << endl;
        if (ans.size() < s.size()) {
            ans = s;
        }
        else if (ans.size() == s.size()) {
            ans = max(ans,s);
        }
    }
    cout << ans << endl;
}

int32_t main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; cin >> t;
    while(t--) solve();
    return 0;
} 

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-17 12:38:41
Judged At
2024-11-11 03:08:21
Judged By
Score
100
Total Time
3ms
Peak Memory
580.0 KiB