Submission #450420

# Submission time Handle Problem Language Result Execution time Memory
450420 2021-08-02T20:37:48 Z rainboy Tuna (COCI17_tuna) C
50 / 50
1 ms 272 KB
#include <stdio.h>

int abs_(int a) { return a > 0 ? a : -a; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
	int n, x, ans;

	scanf("%d%d", &n, &x);
	ans = 0;
	while (n--) {
		int a, b;

		scanf("%d%d", &a, &b);
		if (abs_(a - b) <= x)
			ans += max(a, b);
		else {
			scanf("%d", &a);
			ans += a;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

tuna.c: In function 'main':
tuna.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d", &n, &x);
      |  ^~~~~~~~~~~~~~~~~~~~~
tuna.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d%d", &a, &b);
      |   ^~~~~~~~~~~~~~~~~~~~~
tuna.c:18:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d", &a);
      |    ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 272 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct