Submission #103976

# Submission time Handle Problem Language Result Execution time Memory
103976 2019-04-03T13:22:02 Z igba Fortune Telling 2 (JOI14_fortune_telling2) C++17
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>

using namespace std;
const int MAXN = 2 * 100100, MAXK = 2 * 100100;
int n, k, a[MAXN], b[MAXN], t[MAXK], s[MAXN];
long long ans = 0;

int main()
{
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d %d", &a[i], &b[i]);
		if(a[i] < b[i])
			swap(a[i], b[i]), s[i] = 1;
	}
	for(int i = 1; i <= k; ++i)
		scanf("%d", &t[i]);
	for(int i = 1, j; i <= n; ++i)
	{
		for(j = k; j >= 1; --j)
			if(a[i] <= t[j])
				s[i]++;
			else if(b[i] <= t[j])
				break;
		ans += (s[i] % 2 ? b[i] : a[i]);
	}
	printf("%lld\n", ans);
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~
fortune_telling2.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a[i], &b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -