TOPIC

W.A 5% and nothing...

hart asked 11 months ago

#include <bits/stdc++.h>

using namespace std;

int main(){

int N;

while(cin>>N){

    if(N==0){
        return 0;
    }

    vector<long int>A;
    vector<long int>printa;
    long int aux;

    for(int i=0;i<N;i++){
        cin>>aux;
        A.push_back(aux);
    }

    sort(A.begin(),A.end());

    int cont=0;

    if(A.size()>=3){

        aux=A[0];

        for(int i=1;i<A.size();i++){

            if(i==A.size()-1 && cont<2){
                    printa.push_back(A[i]);
                }

            if(A[i]==aux){
                aux=A[i+1];
                i++;

                    if(i==A.size()-1 && cont<2){
                    printa.push_back(aux);
                }

                continue;
            }

            else{
                printa.push_back(aux);
                aux = A[i];
                cont++;
            }
        }

        sort(printa.begin(),printa.end());
        cout<<printa[0]<<" "<<printa[1]<<endl;
   }

   else{
    if(A.size()==2){
        cout<<A[0]<<" "<<A[1]<<endl;
    }

    if(A.size()==1){
        cout<<A[0]<<endl;
    }

   }

}
    return 0;
}

someone?

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 11 months ago

    Instead of long int use long long int.

  • hart replied 11 months ago

    tnx bro, you're the best