답안 #198783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198783 2020-01-27T15:37:11 Z Neklixx MP3 Player (CEOI10_mp3player) C++14
20 / 100
1000 ms 2156 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));
	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 45 ms 376 KB Output is correct
2 Execution timed out 1086 ms 376 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 923 ms 504 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 743 ms 420 KB Output is correct
4 Correct 24 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 760 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 1093 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 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 1089 ms 2076 KB Time limit exceeded
2 Halted 0 ms 0 KB -