Submission #103982

# Submission time Handle Problem Language Result Execution time Memory
103982 2019-04-03T13:41:22 Z igba Fortune Telling 2 (JOI14_fortune_telling2) C++17
4 / 100
3000 ms 2168 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];
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]);
	for(int i = 1; i <= k; ++i)
		scanf("%d", &t[i]);
	for(int i = 1, swaps, j; i <= n; ++i)
	{
		for(j = k, swaps = 0; j >= 1; --j)
			if(max(a[i], b[i]) <= t[j])
				swaps++;
			else if(min(a[i], b[i]) <= t[j])
			{
				swaps += (a[i] < b[i]);
				break;
			}
		ans += (swaps % 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:12: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:14: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 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 12 ms 768 KB Output is correct
15 Correct 14 ms 1164 KB Output is correct
16 Correct 19 ms 1536 KB Output is correct
17 Correct 27 ms 1968 KB Output is correct
18 Correct 30 ms 2040 KB Output is correct
19 Correct 25 ms 2044 KB Output is correct
20 Correct 39 ms 2012 KB Output is correct
21 Correct 25 ms 2008 KB Output is correct
22 Correct 17 ms 1536 KB Output is correct
23 Correct 17 ms 1536 KB Output is correct
24 Correct 17 ms 1536 KB Output is correct
25 Correct 20 ms 1536 KB Output is correct
26 Correct 2362 ms 1872 KB Output is correct
27 Correct 2734 ms 2168 KB Output is correct
28 Correct 2156 ms 2168 KB Output is correct
29 Execution timed out 3035 ms 2048 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 12 ms 768 KB Output is correct
15 Correct 14 ms 1164 KB Output is correct
16 Correct 19 ms 1536 KB Output is correct
17 Correct 27 ms 1968 KB Output is correct
18 Correct 30 ms 2040 KB Output is correct
19 Correct 25 ms 2044 KB Output is correct
20 Correct 39 ms 2012 KB Output is correct
21 Correct 25 ms 2008 KB Output is correct
22 Correct 17 ms 1536 KB Output is correct
23 Correct 17 ms 1536 KB Output is correct
24 Correct 17 ms 1536 KB Output is correct
25 Correct 20 ms 1536 KB Output is correct
26 Correct 2362 ms 1872 KB Output is correct
27 Correct 2734 ms 2168 KB Output is correct
28 Correct 2156 ms 2168 KB Output is correct
29 Execution timed out 3035 ms 2048 KB Time limit exceeded