Submission #136914

# Submission time Handle Problem Language Result Execution time Memory
136914 2019-07-26T14:06:30 Z dnass Tuna (COCI17_tuna) C++14
50 / 50
7 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

int myabs(int k){
	if(k<0) return -k;
	return k;
}

int n, x;

int main(){
	scanf("%d %d", &n, &x);
	int sum = 0;
	while(n--){
		int p1, p2; scanf("%d %d", &p1, &p2);
		if(myabs(p1-p2)<=x) sum += max(p1, p2);
		else{
			int p3; scanf("%d", &p3);
			sum += p3;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Compilation message

tuna.cpp: In function 'int main()':
tuna.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &x);
  ~~~~~^~~~~~~~~~~~~~~~~
tuna.cpp:15:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int p1, p2; scanf("%d %d", &p1, &p2);
               ~~~~~^~~~~~~~~~~~~~~~~~~
tuna.cpp:18:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int p3; scanf("%d", &p3);
            ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
8 Correct 2 ms 360 KB Output is correct
9 Correct 3 ms 276 KB Output is correct
10 Correct 2 ms 256 KB Output is correct