Submission #198770

# Submission time Handle Problem Language Result Execution time Memory
198770 2020-01-27T14:55:28 Z Neklixx MP3 Player (CEOI10_mp3player) C++14
10 / 100
1000 ms 2548 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 2e9 + 228;
const int MAXN = 1e5 + 228;
int n, vm, v2;
vector<pair<int, int>> v;
pair<bool, int> check(int t) {
	//print2("t", t);
	bool res = 0;
	int x = -1;
	for (int v1 = 0; v1 <= vm; v1++) {
		int nw = v1;
		for (int i = 0; i < n; i++) {
			if (v[i].S > t) {
				continue;
			}
			nw += v[i].F;
			nw = max(0, nw);
			nw = min(vm, nw);
		}
		if (nw == v2) {
			x = v1;
		}
		res |= (nw == v2);
	}
	return {res, x};
}
signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	cin >> n >> vm >> v2;
	int lst = 0;
	for (int i = 0; i < n; i++) {
		int bb;
		char aa;
		cin >> aa >> bb;
		int bbb = bb;
		if (i == 0) {
			bb = INF - 8;
		}
		if (aa == '-') {
			v.pb({-1, bb - lst});
		} else {
			v.pb({1, bb - lst});
		}
		lst = bbb;
	}
	
	if (check(INF - 100).F) {
		cout << "infinity" << endl;
		return 0;
	}
	int mx = 0;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		bool kek = 0;
		int now = 0;
		tie(kek, now) = check(v[i].S - 1);
		//print2(kek, now);
		if (kek) {
			if (mx < v[i].S - 1) {
				ans = now;
			} else if (mx == v[i].S - 1) {
				ans = max(ans, now);
			}
			mx = max(mx, v[i].S - 1);
		}
	}
	cout << mx << ' ' << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 1016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 1016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 1144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 1528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 2548 KB Time limit exceeded
2 Halted 0 ms 0 KB -