Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Mukincs ( 7 years ago )
#include <iostream>
#include<vector>
using namespace std;

int main()
{

    ios_base::sync_with_stdio(false);
    int n,p;
    cin>>n>>p;
    int t[p+1][2];
    int be[n];
     for(int i=0;i<p+1;i++){
        t[i][1]=0;
        t[i][0]=i;
     }
    for(int i=0;i<n;i++){
        cin>>be[i];
        }
    int i=0;
    bool talalt=false;
    int ki1;
    int ki2;
    while(i<n && talalt==false ){
        if(be[i]<p+1){
            if(t[p-be[i]+1][1]!=0){
                talalt=true;
                ki1=t[p-be[i]+1][1];
                ki2=i+1;
        }
        else{
            t[be[i]+1][1]=i+1;
        }
        }
        i++;
    }
    if(talalt==true){
        cout<<ki1<<" "<<ki2;
    }
    else{
        cout<<"-1";
    }
    return 0;
}

 

Revise this Paste

Parent: 99338
Children: 99373
Your Name: Code Language: