#include <bits/stdc++.h>
using namespace std;
int n,t[1000006],res,maxx,ind;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>t[i];
if(maxx<t[i]){
ind=i;
maxx=t[i];
}
}
if(ind==1||ind==n){
cout<<maxx<<" "<<1;
}
else{
cout<<maxx<<" "<<2;
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; int n,t[1000006],res,maxx,ind; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>t[i]; if(maxx<t[i]){ ind=i; maxx=t[i]; } } if(ind==1||ind==n){ cout<<maxx<<" "<<1; } else{ cout<<maxx<<" "<<2; } } |
English