Skip to content

Instantly share code, notes, and snippets.

@waitonza
Created February 24, 2013 10:54
Show Gist options
  • Save waitonza/5023400 to your computer and use it in GitHub Desktop.
Save waitonza/5023400 to your computer and use it in GitHub Desktop.
secondplace of codejom 2013
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int num[10000];
void solve_by_line(){
memset(num, 0, sizeof(num));
int sub_n;
int temp;
scanf("%d%*[\n]",&sub_n);
for (int i = 0; i < sub_n; i++) {
scanf("%d", &temp);
num[i] = temp;
}
sort(num,num+10000);
int max_num = num[9999];
for (int i = 9998; i >= 0; i--) {
if (num[i] < max_num) {
printf("%d\n", num[i]);
break;
}
}
}
int main(){
//File Name
char filename[100] = "secondplace-1";
char file_in[100] = "";
char file_out[100] = "";
strcpy(file_in, filename);
strcpy(file_out, filename);
strcat(file_in, ".in");
strcat(file_out, ".out");
//File input
freopen(file_in,"r",stdin);
//File output
freopen(file_out,"w",stdout);
int n;
scanf("%d%*[\n]",&n);
for(int i=1;i<=n;i++){
solve_by_line();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment