60分,wa3 wa4,求助,本地可过第3组数据
#include <iostream>
#include <algorithm>
#include <cstring>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
struct CanDidate{
int len=0,bh;
char vote[110];
bool operator <(const CanDidate &b)const {
if(len<b.len)return 1;
else if(len==b.len){
if(strcmp(vote,b.vote)==-1)return 1;
}
return 0;
}
};
CanDidate sz[21];
int main(int argc, char** argv) {
// freopen("main.in","r",stdin);
int n;
scanf("%d\n",&n);
char ch;
for(int i=1;i<=n;i++){
sz[i].bh=i;
scanf("%[^\n]\n",&sz[i].vote);
sz[i].len=strlen(sz[i].vote);
}
sort(sz+1,sz+n+1);
printf("%d\n",sz[n].bh);
printf("%s",sz[n].vote);
return 0;
}