about summary refs log tree commit diff
path: root/others/easy20160714/04.c
blob: d6c0a477bbacecc7ba1ceee223c5fdffc4176c18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>

int main()
{
	FILE *f = fopen("INP.TXT", "r");
	char n, i, j;
	short m, *a;

	fscanf(f, "%hhd %hd", &n, &m);
	a = malloc(n * sizeof(short));

	for (i = 0; i < n; i++)
		fscanf(f, "%hd", a + i);

	fclose(f);

	f = fopen("OUT.TXT", "w");

	for (i = 0; i + 1 < n; i++)
		for (j = i + 1; j < n; j++)
			if (a[i] + a[j] == m) {
				fprintf(f, "%hhd %hhd\n", i + 1, j + 1);

				fclose(f);

				return 0;
			}

	fputs("-1\n", f);

	fclose(f);

	return 0;
}