/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 9ms 9.582 MiB
#2 Accepted 13ms 9.598 MiB
#3 Accepted 13ms 9.723 MiB
#4 Accepted 13ms 9.574 MiB
#5 Accepted 13ms 9.566 MiB
#6 Accepted 13ms 9.602 MiB
#7 Accepted 13ms 9.703 MiB
#8 Accepted 10ms 9.609 MiB
#9 Accepted 10ms 9.512 MiB
#10 Accepted 13ms 9.57 MiB
#11 Accepted 10ms 9.66 MiB
#12 Accepted 11ms 9.645 MiB
#13 Accepted 14ms 9.598 MiB
#14 Accepted 12ms 9.699 MiB
#15 Accepted 12ms 9.664 MiB

Code

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

const int N = 3e5 + 9;
const int inf = 3e10 + 9;

// int a[N], b[N];

int dp[1003][103];

string s[N];

vector<int> v[7];

std::map<string, int> mp;

string mx(string a, string b)
{
    if(a.size() > b.size()) return a;
    else if(a.size() == b.size()) return max(a, b);
    else return b;
}

int32_t main() {

    int tc = 1;
    cin >> tc;
    while(tc--) {
        int n, k; cin >> n >> k;
        // cout << max(c1, c2);
        for (int i = 0; i < n; ++i)
        {
            cin >> s[i];
        }
        string ans = "";
        for(int i = 0; i < n; i++)
        {
            string tmp = "";
            for(int j = i; j <= i + k && j < n; j++)
            {
                tmp += s[j];
            }
            ans = mx(ans, tmp);
        }
        cout << ans << endl;
    }

    return 0;
}

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:07:16
Judged At
2024-10-03 13:28:33
Judged By
Score
100
Total Time
14ms
Peak Memory
9.723 MiB