Submission #335136

# Submission time Handle Problem Language Result Execution time Memory
335136 2020-12-11T08:26:34 Z VodkaInTheJar Fortune Telling 2 (JOI14_fortune_telling2) C++14
4 / 100
3000 ms 1644 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'

using namespace std;

const int maxn = 2e5 + 3; 

int n, k; 
int a[maxn], b[maxn], t[maxn];
void read()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	cin >> a[i] >> b[i];
	
	for (int i = 1; i <= k; i++)
	cin >> t[i];
}

void solve()
{
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		bool is = false;
		for (int j = 1; j <= k; j++)
		{
			int border = (is ? b[i] : a[i]);
			if (t[j] >= border)
			is ^= 1; 
		}
		
		if (!is)
		ans += a[i];
		
		else
		ans += b[i];
	}
	
	cout << ans << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	read();
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 5 ms 364 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 4 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 5 ms 364 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 4 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 345 ms 876 KB Output is correct
15 Correct 1369 ms 1260 KB Output is correct
16 Execution timed out 3053 ms 1644 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 5 ms 364 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 4 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 345 ms 876 KB Output is correct
15 Correct 1369 ms 1260 KB Output is correct
16 Execution timed out 3053 ms 1644 KB Time limit exceeded
17 Halted 0 ms 0 KB -