답안 #250301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250301 2020-07-17T11:16:41 Z mode149256 Pinball (JOI14_pinball) C++14
0 / 100
1 ms 384 KB
/*input
5 6
2 4 3 5
1 2 2 8
3 6 5 2
4 6 4 7
2 4 3 10

3 5
2 4 3 10
1 3 1 20
2 5 4 30
*/
#include <bits/stdc++.h>
using namespace std;

namespace my_template {
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}
}
using namespace my_template;

const int MOD = 1000000007;
const ll INF = 1e14;
const int MX = 100101;

struct tral {
	int a, b, c, d;
};

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int M, N;
	cin >> M >> N;
	vector<tral> sk(M);
	for (int i = 0; i < M; ++i)
	{
		int a, b, c, d; cin >> a >> b >> c >> d;
		sk[i] = {a, b, c, d};
	}

	reverse(sk.begin(), sk.end());
	int l = sk[0].a;
	int r = sk[0].b;

	// for (int i = 1; i < M; ++i)
	// {
	// 	if (l <= sk[i].c and sk[i].c <= r) {
	// 		l = min(l, sk[i].a);
	// 		r = max(r, sk[i].b);
	// 	}
	// }

	// printf("l = %d, r = %d\n", l, r);
	// if (l != 1 or r != N) return !printf("-1\n");


	ll ats = INF;

	for (int m = 0; m < M; ++m)
	{
		ll suma = sk[m].d;
		l = sk[m].a;
		r = sk[m].b;
		for (int i = m; i < M; ++i)
		{
			if (l <= sk[i].c and sk[i].c <= r and (sk[i].a < l or r < sk[i].b)) {
				l = min(l, sk[i].a);
				r = max(r, sk[i].b);
				suma += sk[i].d;
			}
		}

		if (l == 1 and r == N)
			ats = min(ats, suma);
	}

	if (ats == INF) printf("-1\n");
	else printf("%lld\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -