107182024-04-10 12:39:11eokorKörJáték (50 pont)cpp17Time limit exceeded 25/50600ms3620 KiB
#include <bits/stdc++.h>
using namespace std;

bool fg(pair<int,int>a,pair<int,int>b){
        return a.second < b.second;
}

int main()
{
    int n;
    cin>>n;
    vector <pair<int,int>>s;
    vector <pair<int,int>>s1;
    int meg[n+1]={};
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        s.push_back(make_pair(i,x));
    }
    sort(s.begin(),s.end(),fg);
    int x,osszeg=0;
    for(int i=0;i<n;i++)
    {
        s1 = s;
        s[i].second=n+1;
        sort(s.begin(),s.end(),fg);
         cout<<endl;
        for(int j=1;j<n;j++)
        {
            if(s[j-1].first < s[j].first)
                osszeg+=s[j].first-s[j-1].first;
            else osszeg+=n+s[j].first-s[j-1].first;
        }
        s=s1;
        meg[s[i].first] = osszeg;
        osszeg=0;
    }
    for(int i=1;i<=n;i++)
        cout<<meg[i]<<" ";
}

SubtaskSumTestVerdictTimeMemory
base25/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2068 KiB
3Accepted0/03ms2084 KiB
4Accepted2/23ms2216 KiB
5Accepted2/23ms2608 KiB
6Accepted2/23ms2704 KiB
7Accepted2/23ms2792 KiB
8Accepted2/23ms2852 KiB
9Accepted2/23ms2736 KiB
10Accepted2/23ms3008 KiB
11Accepted2/23ms3260 KiB
12Accepted2/23ms3344 KiB
13Accepted2/23ms3472 KiB
14Accepted2/23ms3452 KiB
15Accepted2/23ms3456 KiB
16Accepted1/13ms3620 KiB
17Time limit exceeded0/2600ms3452 KiB
18Time limit exceeded0/2565ms3480 KiB
19Time limit exceeded0/2528ms3428 KiB
20Time limit exceeded0/2541ms3404 KiB
21Time limit exceeded0/2545ms3344 KiB
22Time limit exceeded0/2569ms3344 KiB
23Time limit exceeded0/2564ms3528 KiB
24Time limit exceeded0/2560ms3480 KiB
25Time limit exceeded0/2556ms3524 KiB
26Time limit exceeded0/2578ms3472 KiB
27Time limit exceeded0/2569ms3604 KiB
28Time limit exceeded0/2549ms3552 KiB
29Time limit exceeded0/1578ms3580 KiB