Skip to content

Commit

Permalink
Add kattis prob parking2 in C
Browse files Browse the repository at this point in the history
  • Loading branch information
iandioch committed Mar 12, 2017
1 parent a547f68 commit 66f397e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions kattis/parking2/solution.c
@@ -0,0 +1,26 @@
#include <stdio.h>

int main() {
int num_tests;
scanf("%d", &num_tests);
int t;
for (t = 0; t < num_tests; ++t) {
int n;
scanf("%d", &n);
unsigned int min = -1;
int max = 0;
int i;
for (i = 0; i < n; ++i) {
int x;
scanf("%d", &x);
if (x < min) {
min = x;
}
if (x > max) {
max = x;
}
}
printf("%d\n", 2*(max-min));
}
return 0;
}

0 comments on commit 66f397e

Please sign in to comment.