This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
mp3player.cpp:2:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker,"/stack:200000000")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |