Submission #473631

# Submission time Handle Problem Language Result Execution time Memory
473631 2021-09-15T18:34:29 Z MamdouhN Doktor (COCI17_doktor) C++17
80 / 100
606 ms 38216 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

map<pair<int,int>,int>idk;

main()
{
    int n;
    cin>>n;
    int ar[n];
    int doingnothing=0;
    vector<int>lol;
    lol.push_back(0);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]==i+1)doingnothing++;
        int x = min(ar[i]-1,i);
        int y = max(ar[i]-1,i);
        int dist = min(x - 0 , n - y-1);
        //cout<<x-dist<<" "<<y+dist<<endl;
        idk[{ x-dist , y+dist }]++;
        lol.push_back(doingnothing);
    }
    int x = 0;
    pair<int,int>ans;
    for(auto v:idk)
    {
        int z = lol[v.first.second+1] - lol[v.first.first];
        if(v.second-z>x)
        {
            x = v.second;
            ans = v.first;
        }
    }
    cout<<ar[ans.first]<<" "<<ar[ans.second]<<endl;
}

Compilation message

doktor.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 844 KB Output is correct
2 Correct 103 ms 6768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 5788 KB Output is correct
2 Correct 34 ms 2876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 606 ms 30468 KB Output is correct
2 Correct 173 ms 8464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 18836 KB Output is correct
2 Correct 298 ms 38216 KB Output is correct