Submission #553701

# Submission time Handle Problem Language Result Execution time Memory
553701 2022-04-26T16:15:27 Z QwertyPi Fortune Telling 2 (JOI14_fortune_telling2) C++14
4 / 100
3000 ms 1756 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+3;
int A[N], B[N], C[N];
int x1[N], x2[N], pa[N];
struct BIT{
	int bit[N];
	void upd(int p, int v){
		for(int i = p; i < N; i += i & -i){
			bit[i] += v;
		}
	}
	int qry(int p){
		int ret = 0;
		for(int i = p; i; i -= i & -i){
			ret += bit[i];
		}
		return ret;
	}
} bit0, bit1;

int32_t main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> A[i] >> B[i];
		x1[i] = min(A[i], B[i]);
		x2[i] = max(A[i], B[i]);
		pa[i] = x1[i] != A[i];
	}
	for(int i = 0; i < k; i++){
		cin >> C[i];
	}
	// A[i] <= C[i] < B[i]
	long long ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < k; j++){
			if(x1[i] <= C[j] && C[j] < x2[i]){
				pa[i] = true;
			}else if(x2[i] <= C[j]){
				pa[i] ^= 1;
			}
		}
		ans += pa[i] ? x2[i] : x1[i];
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 320 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 2 ms 328 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 5 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 320 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 2 ms 328 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 5 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 509 ms 852 KB Output is correct
15 Correct 2013 ms 1356 KB Output is correct
16 Execution timed out 3061 ms 1756 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 328 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 320 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 4 ms 340 KB Output is correct
9 Correct 2 ms 328 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 5 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 509 ms 852 KB Output is correct
15 Correct 2013 ms 1356 KB Output is correct
16 Execution timed out 3061 ms 1756 KB Time limit exceeded
17 Halted 0 ms 0 KB -