QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764298 | #7781. Sheep Eat Wolves | fosov | WA | 0ms | 3672kb | C++14 | 1.2kb | 2024-11-20 08:32:54 | 2024-11-20 08:33:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define ld long double
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define N 110
int dp[N][N][2];
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << setprecision(18);
int x, y, p, q; cin >> x >> y >> p >> q;
int sx = 0, sy = max(0, y - x - q);
y -= sy;
int tx = 0, ty = 0;
int d = INF, stp = 0;
while (stp < 1e5) {
d = min(p - sx - sy, max(0, x - (y - q)));
sx += d, x -= d;
if (p - sx >= x) sy = 0, sx += x, x = 0;
d = min((p - sx - sy) / 2, min(x, y));
sx += d, sy += d, x -= d, y -= d;
++ stp;
if (tx == 0) ty += sy, sy = 0;
tx += sx, sx = 0;
d = min(sy, max(0, tx + q - ty));
ty += d, sy -= d;
if (tx) d = max(0, ty - tx - q), sy += d, ty -= d;
if (x == 0) break;
++ stp;
}
cout << (stp == int(1e5) ? -1 : stp) << '\n';
}
// 3 3
// 2 2
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
2 5 1 1
output:
63
result:
wrong answer 1st numbers differ - expected: '-1', found: '63'