Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- unsigned Abs(unsigned a, unsigned b) {
- if (a > b)
- return a - b;
- return b - a;
- }
- int main() {
- unsigned i, j, k, n, dist, distMaxim = 0;
- FILE *f;
- f = fopen("srv.in", "r");
- if (!f) return 0;
- fscanf(f, "%u", &n);
- for (k = 1; k <= n; k++) {
- fscanf(f, "%u%u", &i, &j);
- if (Abs(i, j) <= n)
- dist = Abs(i, j);
- else
- dist = 2 * n - Abs(i, j);
- if (dist > distMaxim)
- distMaxim = dist;
- }
- fclose(f);
- f = fopen("srv.out", "w");
- fprintf(f, "%u", distMaxim);
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement