/ SeriousOJ /

Record Detail

Accepted


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

Code

#include <bits/stdc++.h>
#define ll long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int mod = 1e9 + 7, N = 1e6;

void solve()
{
  int n, k;
  cin >> n >> k;
  int mx = 0;
  int ar[n + 3];
  for (int i = 1; i <= n; i++)
    cin >> ar[i], mx = max(ar[i], mx);
  string s = to_string(mx);
  for (int i = 1; i <= n; i++)
  {
    string x;
    for (int j = i; j <= min(n, i + k); j++)
    {
      x += to_string(ar[j]);
    }
    if (x.size() > s.size())
    {
      s = x;
    }
    else if (x.size() == s.size())
    {
      s = max(s, x);
    }
  // cout << s << " " << x << endll;
  }

  cout << s << endll;
}

int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--)
  {
    solve();
  }
  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 15:47:36
Judged At
2024-11-11 03:17:19
Judged By
Score
100
Total Time
11ms
Peak Memory
592.0 KiB