Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created August 17, 2012 03:28
Show Gist options
  • Save iporsut/3375685 to your computer and use it in GitHub Desktop.
Save iporsut/3375685 to your computer and use it in GitHub Desktop.
ZOJ 2970: Faster, Higher, Stronger
#include <stdio.h>
#include <string.h>
#define min(A,B) (A < B)?A:B
#define max(A,B) (A > B)?A:B
int main() {
int test, n, v, best;
char type[9];
scanf("%d", &test);
while(test != 0) {
scanf("%s", type);
scanf("%d", &n);
if ( ! strcmp(type,"Faster")) {
best = 999999999;
while(n != 0) {
scanf("%d", &v);
best = min(best,v);
n--;
}
printf("%d\n", best);
} else {
best = 0;
while(n != 0) {
scanf("%d", &v);
best = max(best,v);
n--;
}
printf("%d\n", best);
}
test--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment