답안 #302765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
302765 2020-09-19T07:38:16 Z hexan 운세 보기 2 (JOI14_fortune_telling2) C++14
컴파일 오류
0 ms 0 KB
#include "factories.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define size(x) (ll)x.size()
#define x first
#define y second
#define chkmax(x, y) x = max(x, y)
#define chkmin(x, y) x = min(x, y)
 
const int N = 2e5 + 1;
int a[N], b[N], t[N];

int get(int l, int r, int x) {
	int ret = 0;
	while (l <= r) {
		ret += (t[l++] >= x);
	}
	return ret;
}

void run() {
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	vector<pair<int, int>> arr;
	for(int i = 0; i < k; i++) {
		cin >> t[i];
		arr.emplace_back(t[i], i);
	}
	sort(all(arr));
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int pos = lower_bound(all(arr), make_pair(max(a[i], b[i]), 0)) - arr.begin() - 1;
		if (pos == -1) continue;
		if (min(a[i], b[i]) <= arr[pos].first && arr[pos].first < max(a[i], b[i])) {
			if (a[i] < b[i]) swap(a[i], b[i]);
			if (get(arr[pos].second + 1, n - 1, max(a[i], b[i])) & 1) ans += b[i];
			else ans += a[i];
		} else {
			if (get(0, n - 1, a[i]) & 1) ans += b[i];
			else ans += a[i];
		}
	}

	cout << ans;
}

int main() {
#ifdef LOCAL
	freopen("input", "r", stdin);
	freopen("output", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	run();
}

Compilation message

fortune_telling2.cpp:1:10: fatal error: factories.h: No such file or directory
    1 | #include "factories.h"
      |          ^~~~~~~~~~~~~
compilation terminated.