답안 #198785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198785 2020-01-27T15:40:42 Z Neklixx MP3 Player (CEOI10_mp3player) C++14
30 / 100
1000 ms 2160 KB
#pragma GCC optimize("Ofast")
#pragma comment(linker,"/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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;
inline pair<bool, int> check(int t) {
	//print2("t", t);
	bool res = 0;
	int x = -1;
	for (int v1 = vm; v1 >= 0; 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) {
			return {1, 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;
	vector<int> k;
	for (int i = 1; i < n; i++) {
		k.pb(v[i].S - 1);
	}
	sort(all(k));
	k.erase(unique(all(k)), k.end());
	reverse(all(k));
	for (int i = 1; i < n; i++) {
		bool kek = 0;
		int now = 0;
		tie(kek, now) = check(k[i]);
		//print2(kek, now);
		if (kek) {
			cout << k[i] << ' ' << now << endl;
			return 0;
		}
	}
	cout << mx << ' ' << ans << endl;
    return 0;
}

Compilation message

mp3player.cpp:2:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker,"/stack:200000000")
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 77 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 765 ms 444 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 21 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 1140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 2156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 2160 KB Time limit exceeded
2 Halted 0 ms 0 KB -