998A - Balloons - CodeForces Solution


constructive algorithms implementation *1000

Please click on ads to support us..

Python Code:

n=int(input())
l=input().split()
l1=[int(num) for num in l]
l1.sort()
a,b=0,0
if len(l1)==1:print(-1)
else:
    a+=l1[0]
    b+=sum(l1[1:])
    if a==b:print(-1)
    else:
        print(1)
        print(str(l.index(str(a))+1))

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main(){
        int n;
        cin>>n;
        int A[n];
        for(int i = 0 ; i < n ; i++){
                cin>>A[i];
        }
        if((n==0)||(n==1)||(A[0] == A[n-1] && n == 2)){
                cout<<"-1"<<endl;
        }
        else{
            int min=INT_MAX;
            int index=-1;
                cout<<1<<endl;
                for(int i = 0 ; i<n ; i++){
                       if(A[i]<min){
                           min=A[i];
                           index=i;
                       }
                }
                cout<<index+1;
        }
        
}


Comments

Submit
0 Comments
More Questions

1663C - Pōja Verdon
1497A - Meximization
1633B - Minority
688B - Lovely Palindromes
66B - Petya and Countryside
1557B - Moamen and k-subarrays
540A - Combination Lock
1553C - Penalty
1474E - What Is It
1335B - Construct the String
1004B - Sonya and Exhibition
1397A - Juggling Letters
985C - Liebig's Barrels
115A - Party
746B - Decoding
1424G - Years
1663A - Who Tested
1073B - Vasya and Books
195B - After Training
455A - Boredom
1099A - Snowball
1651D - Nearest Excluded Points
599A - Patrick and Shopping
237A - Free Cash
1615B - And It's Non-Zero
1619E - MEX and Increments
34B - Sale
1436A - Reorder
1363C - Game On Leaves
1373C - Pluses and Minuses