제출 #1369796

#제출 시각아이디문제언어결과실행 시간메모리
1369796turkeyorzGift Boxes (EGOI25_giftboxes)C++20
36 / 100
2094 ms6240 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    int t, n;
    cin>>t>>n;
    vector<int> a(n), cnt(t, 0);
    for(auto &i : a) {
        cin>>i;
        ++cnt[i];
    }
    pair<int, int> p = {-1, -1};
    int tot = n - t;
    for(int i=0;i<n;++i) {
        int tot2 = 0;
        vector<int> cnt2(t, 0);
        for(int j=i;j<n;++j) {
            if(cnt[a[j]] > 1) {
                ++tot2;
                if(tot2 == tot) {
                    if(p.first == -1 || p.second - p.first + 1 > j - i + 1) {
                        p = {i, j};
                    }
                }
            }
            --cnt[a[j]];
            ++cnt2[a[j]];
        }
        for(int i=0;i<t;++i)    
            cnt[i] += cnt2[i];
    }
    cout<<p.first<<' '<<p.second<<'\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…