QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#445702 | #8528. Chords | ucup-team1231# | WA | 1ms | 3968kb | C++20 | 1.0kb | 2024-06-16 09:32:42 | 2024-06-16 09:32:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
int poss[200001];
int dp[200001][1000];
int main() {
int i;
int n,a,b;
scanf("%d",&n);
fill(poss,poss+2*n+1,-1);
for (i = 0; i < n; i++) scanf("%d %d",&a,&b),poss[b] = a;
int j,B = 1000;
for (i = 0; i < B; i++) dp[0][i] = (i == 0) ? 0:1e9;
for (i = 1; i <= 2*n; i++) {
for (j = 0; j < B; j++) dp[i][j] = (j == 0) ? i:dp[i-1][j];
if (poss[i] != -1) {
for (j = 0; j < B; j++) {
if (i-1-dp[i-1][j] <= poss[i]) break;
}
int c = j;
for (j = 0; j+c+1 < B; j++) {
dp[i][j+c+1] = min(dp[i][j+c+1],dp[poss[i]][j]);
if (dp[poss[i]][j] == 1e9) break;
}
}
}
for (i = 0; i < B; i++) {
if (dp[2*n][i] == 1e9) break;
}
printf("%d\n",i-1);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
5 1 2 4 10 7 9 3 5 6 8
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
2 1 3 2 4
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
2 1 4 2 3
output:
1
result:
wrong answer 1st numbers differ - expected: '2', found: '1'