/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Wrong Answer 1ms 328.0 KiB

Code

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using lld = long double;
using ull = unsigned long long;
const ll mod=1000000007;


#define vr(v) v.begin(),v.end()
#define rv(v) v.end(),v.begin()
#define nline "\n"

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);} //__gcd
ll lcm(ll a, ll b){return (a/gcd(a,b)*b);} // lcm

bool assen(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
bool desen(const pair<int,int> &a,const pair<int,int> &b){return (a.second > b.second);}

bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}


void solve(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>>vp(n);
    for(int i=1;i<=n;i++){
        cin>>vp[i].first;
        vp[i].second = i;
    }

    sort(vp.begin(),vp.end(),assen);

    int l = 0 , r = 0;
    for(int i=1;i<=n;i++){
        if(vp[i].first != vp[i].second){
            l = vp[i].second;
            break;
        }
    }

    for(int i=l+1;i<=n;i++){
        if(vp[i].first != vp[i].second){
            r = vp[i].second;
        }
    }

    if(r-l+1 > k){
        cout<<"NO"<<nline;
    }
    else{
        cout<<"YES"<<nline;
        cout<<vp[l].first<<" "<<vp[r].first<<nline;
    }
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int test_case=1;  //cin>>test_case;
    while(test_case--){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 14:53:02
Judged At
2024-11-11 02:32:16
Judged By
Score
4
Total Time
1ms
Peak Memory
532.0 KiB