QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554529 | #8780. Training, Round 2 | appear | WA | 36ms | 199348kb | C++14 | 1.1kb | 2024-09-09 11:48:21 | 2024-09-09 11:48:22 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e3 + 5;
struct Node{
int ax, ay, bx, by;
}s[N];
int n, a, b, dp[N][N];
signed main(){
cin >> n >> a >> b;
for(int i = 1; i <= n; i++){
cin >> s[i].ax >> s[i].ay >> s[i].bx >> s[i].by;
}
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++) dp[i][j] = -N;
}
dp[0][0] = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= i; j++){
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
int na = 0, nb = 0;
na = a + j, nb = b + dp[i - 1][j] - j;
if(na >= s[i].ax && na <= s[i].ay && nb >= s[i].bx && nb <= s[i].by){
dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
}
if(j){
na = a + j - 1, nb = b + dp[i - 1][j - 1] - j + 1;
if(na >= s[i].ax && na <= s[i].ay && nb >= s[i].bx && nb <= s[i].by){
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
}
}
}
}
int ans = 0;
for(int i = 0; i <= n; i++){
ans = max(ans, dp[n][i]);
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
3 0 0 0 1 0 1 1 1 0 1 1 1 1 1
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 32ms
memory: 199260kb
input:
5000 801577551 932138594 801577551 801577551 932138594 932138594 801577552 801577552 932138594 932138594 801577552 801577552 932138595 932138595 801577552 801577552 932138596 932138596 801577553 801577553 932138596 932138596 801577553 801577553 932138597 932138597 801577553 801577553 932138598 93213...
output:
5000
result:
ok single line: '5000'
Test #3:
score: 0
Accepted
time: 35ms
memory: 199348kb
input:
5000 932138594 801577551 932138594 932138594 801577551 801577551 932138594 932138594 801577552 801577552 932138595 932138595 801577552 801577552 932138596 932138596 801577552 801577552 932138596 932138596 801577553 801577553 932138597 932138597 801577553 801577553 932138598 932138598 801577553 80157...
output:
5000
result:
ok single line: '5000'
Test #4:
score: 0
Accepted
time: 36ms
memory: 199344kb
input:
5000 76836128 716580777 76836128 76836128 716580777 716580777 76836129 76836129 716580777 716580777 76836130 76836130 716580777 716580777 76836131 76836131 716580777 716580777 76836131 76836131 716580778 716580778 76836131 76836131 716580779 716580779 76836131 76836131 716580780 716580780 76836128 7...
output:
4994
result:
ok single line: '4994'
Test #5:
score: -100
Wrong Answer
time: 32ms
memory: 199340kb
input:
5000 716580777 76836128 716580777 716580777 76836128 76836128 716580777 716580777 76836129 76836129 716580777 716580777 76836130 76836130 716580777 716580777 76836131 76836131 716580778 716580778 76836131 76836131 716580779 716580779 76836131 76836131 716580780 716580780 76836131 76836131 716580778 ...
output:
7
result:
wrong answer 1st lines differ - expected: '4994', found: '7'