QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129670 | #4541. Black Magic | batrr# | AC ✓ | 9ms | 3636kb | C++17 | 1.3kb | 2023-07-22 21:58:19 | 2023-07-22 21:58:20 |
Judging History
answer
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const int N = 300500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;
int sum(int a, int b) {
a += b;
if (a >= mod)
a -= mod;
return a;
}
int sub(int a, int b) {
a -= b;
if (a < 0)
a += mod;
return a;
}
int mult(int a, int b) {
return 1ll * a * b % mod;
}
int bp(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
int inv(int x) {
return bp(x, mod - 2);
}
ll e, l, r, b;
void solve() {
cin >> e >> l >> r >> b;
ll tot = e + l + r + b;
ll mrg_min = max(0LL, b - e - 1);
ll MX = tot - mrg_min;
ll mx_mrg = min({l + r + b - 1, l + b, r + b});
mx_mrg = max(mx_mrg, 0LL);
cout << tot - mx_mrg << " " << MX << '\n';
}
int main() {
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << endl;
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 3636kb
input:
4000 0 0 0 1 0 0 0 100000 0 0 0 11 0 0 0 12 0 0 0 13 0 0 0 2 0 0 0 25 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 6 0 0 0 7 0 0 0 8 0 0 0 9 0 0 1 0 0 0 1 1 0 0 1 12 0 0 1 14 0 0 1 17 0 0 1 2 0 0 1 21 0 0 1 3 0 0 1 4 0 0 1 5 0 0 1 6 0 0 1 7 0 0 1 8 0 0 1 9 0 0 100000 0 0 0 11 6 0 0 12 3 0 0 12 4 0 0 13 0 0 0 13 12...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 100000 100000 11 12 12 13 12 13 13 13 13 14 13 14 14 15 16 16 16 17 16 17 2 2 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 26 27 3 3 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 4 4 4 5 ...
result:
ok 4000 lines