제출 #320159

#제출 시각아이디문제언어결과실행 시간메모리
320159Karen124MP3 Player (CEOI10_mp3player)C++14
10 / 100
1069 ms2780 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; #define ll long long int #define F first #define S second #define pb push_back const ll N = 1e5 + 5; const ll LOG = 30; const ll MOD = 1e9 + 7; const ll INF = 2e9 + 10; int n, Vmax, V2, a[N], t[N], ansT = -1, ansV1; vector <int> dif; int R_Do_Operations(int e, int T){ for (int i = n; i >= 2; i--){ if (t[i] - t[i - 1] <= T){ e -= a[i]; } e = max(e, 0); e = min(e, Vmax); } return e; } int Do_Operations(int s, int T){ for (int i = 2; i <= n; i++){ if (t[i] - t[i - 1] <= T){ s += a[i]; } s = max(s, 0); s = min(s, Vmax); } return s; } int ok(int T){ int s = R_Do_Operations(V2, T); int e = Do_Operations(s, T); return (e == V2); } int main (){ assert(n <= 4000); cin >> n >> Vmax >> V2; for (int i = 1; i <= n; i++){ char c; cin >> c >> t[i]; a[i] = ((c == '+') ? 1 : -1); if (i != 1) dif.pb(t[i] - t[i - 1]); } if (ok(INF)) return cout << "infinity\n", 0; dif.pb(0); sort(dif.begin(), dif.end()); for (int x : dif){ if (ok(x) && ansT <= x){ ansT = x; ansV1 = R_Do_Operations(V2, x); } } for (int i = min(Vmax - ansV1, n); i >= 0; i--){ if (Do_Operations(ansV1 + i, ansT) == V2){ cout << ansT << ' ' << ansV1 + i << '\n'; return 0; } } /*if (ok(INF, 0)) return cout << "infinity\n", 0; int l = 0, r = INF; while (l + 1 < r){ int mid = (l + r) / 2; if (ok(mid, 0)) l = mid; else r = mid; } cout << l << ' ' << ok(l, 1) << '\n';*/ return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...