QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757622#7781. Sheep Eat WolvesCUHK_723WA 1ms4068kbC++141.1kb2024-11-17 11:18:142024-11-17 11:18:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-17 11:18:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4068kb
  • [2024-11-17 11:18:14]
  • 提交

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'