Submission #52219

# Submission time Handle Problem Language Result Execution time Memory
52219 2018-06-25T05:12:54 Z 윤교준(#1348) Fortune Telling 2 (JOI14_fortune_telling2) C++11
4 / 100
2000 ms 752 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 200005;
const int MAXK = 200005;

int A[MAXN], B[MAXN];
int C[MAXK];

bitset<MAXN> chk;

ll Ans;
int N, K;

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", &C[i]);

	for(int i = 1; i <= K; i++) {
		int c = C[i];
		for(int j = 1; j <= N; j++) {
			if(!chk[j] && A[j] <= c) chk[j] = !chk[j];
			else if(chk[j] && B[j] <= c) chk[j] = !chk[j];
		}
	}

	for(int i = 1; i <= N; i++)
		Ans += chk[i] ? B[i] : A[i];
	
	printf("%lld\n", Ans);
	return 0;
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:17: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:18:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= N; i++) scanf("%d%d", &A[i], &B[i]);
                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:19:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= K; i++) scanf("%d", &C[i]);
                              ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 12 ms 480 KB Output is correct
5 Correct 12 ms 536 KB Output is correct
6 Correct 12 ms 672 KB Output is correct
7 Correct 12 ms 672 KB Output is correct
8 Correct 12 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 5 ms 724 KB Output is correct
11 Correct 12 ms 724 KB Output is correct
12 Correct 12 ms 724 KB Output is correct
13 Correct 12 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 12 ms 480 KB Output is correct
5 Correct 12 ms 536 KB Output is correct
6 Correct 12 ms 672 KB Output is correct
7 Correct 12 ms 672 KB Output is correct
8 Correct 12 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 5 ms 724 KB Output is correct
11 Correct 12 ms 724 KB Output is correct
12 Correct 12 ms 724 KB Output is correct
13 Correct 12 ms 724 KB Output is correct
14 Correct 937 ms 752 KB Output is correct
15 Execution timed out 2055 ms 752 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 12 ms 480 KB Output is correct
5 Correct 12 ms 536 KB Output is correct
6 Correct 12 ms 672 KB Output is correct
7 Correct 12 ms 672 KB Output is correct
8 Correct 12 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 5 ms 724 KB Output is correct
11 Correct 12 ms 724 KB Output is correct
12 Correct 12 ms 724 KB Output is correct
13 Correct 12 ms 724 KB Output is correct
14 Correct 937 ms 752 KB Output is correct
15 Execution timed out 2055 ms 752 KB Time limit exceeded
16 Halted 0 ms 0 KB -