답안 #335139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335139 2020-12-11T08:31:24 Z VodkaInTheJar 운세 보기 2 (JOI14_fortune_telling2) C++14
4 / 100
3000 ms 1004 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 5 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 4 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 5 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 4 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 343 ms 748 KB Output is correct
15 Correct 1358 ms 748 KB Output is correct
16 Execution timed out 3065 ms 1004 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 5 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 4 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 343 ms 748 KB Output is correct
15 Correct 1358 ms 748 KB Output is correct
16 Execution timed out 3065 ms 1004 KB Time limit exceeded
17 Halted 0 ms 0 KB -