107192024-04-10 12:44:27eokorKörJáték (50 pont)cpp17Time limit exceeded 25/50600ms3576 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,y,osszeg=0;
    for(int i=0;i<n;i++)
    {
        s1 = s;
        s[i].second=n+1;
        x=s[i].first;
        y=s[i].second;
        s.erase(s.begin()+i);
        s.push_back(make_pair(x,y));
        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/03ms2088 KiB
2Accepted0/03ms2148 KiB
3Accepted0/03ms2520 KiB
4Accepted2/23ms2548 KiB
5Accepted2/23ms2496 KiB
6Accepted2/22ms2500 KiB
7Accepted2/23ms2496 KiB
8Accepted2/23ms2624 KiB
9Accepted2/23ms2700 KiB
10Accepted2/23ms2764 KiB
11Accepted2/23ms2764 KiB
12Accepted2/23ms2884 KiB
13Accepted2/23ms2900 KiB
14Accepted2/23ms2932 KiB
15Accepted2/23ms3044 KiB
16Accepted1/13ms3100 KiB
17Time limit exceeded0/2600ms2952 KiB
18Time limit exceeded0/2573ms3044 KiB
19Time limit exceeded0/2554ms3056 KiB
20Time limit exceeded0/2554ms3028 KiB
21Time limit exceeded0/2578ms3024 KiB
22Time limit exceeded0/2546ms3280 KiB
23Time limit exceeded0/2578ms3252 KiB
24Time limit exceeded0/2552ms3328 KiB
25Time limit exceeded0/2577ms3392 KiB
26Time limit exceeded0/2564ms3408 KiB
27Time limit exceeded0/2556ms3360 KiB
28Time limit exceeded0/2549ms3576 KiB
29Time limit exceeded0/1556ms3420 KiB