QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#757622 | #7781. Sheep Eat Wolves | CUHK_723 | WA | 1ms | 4068kb | C++14 | 1.1kb | 2024-11-17 11:18:14 | 2024-11-17 11:18:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int x, y, p, q;
int dp[110][110][110];
void solve() {
dp[0][x][y] = 1;
for(int i = 1; i <= 100; ++i) {
for(int j = 0; j <= x; ++j) {
for(int k = 0; k <= y; ++k) {
for(int l = 0; l <= p; ++l) {
if(i % 2 == 0) {
if((x - j + q < y - k && x - j >= 1) || k < l) continue;
else dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k - l]);
if(dp[i][j][k] == 1 && p >= j) {
cout << i + 1;
return;
}
}
else {
if(j + q < k) continue;
else dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j + (p - l)][k + l]);
}
//cout << i << " " << j << " " << k << " " << l << " " << dp[i][j][k] << endl;
}
}
}
}
cout << -1;
return;
}
int main() {
x = read();
y = read();
p = read();
q = read();
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
4 4 3 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
3 5 2 0
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4068kb
input:
2 5 1 1
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
1 1 1 0
output:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'