QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141160 | #6525. New Houses | cy1999 | WA | 4ms | 15088kb | C++ | 508b | 2023-08-17 09:08:15 | 2023-08-17 09:08:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int const maxn = 5e5+10;
#define int long long
int dp[maxn*2];
int a[maxn],b[maxn];
signed main(){
int t;
cin >> t ;
while(t--){
int n,m;
cin >> n >> m ;
for(int i = 1;i <= n;i ++){
cin >>a[i] >> b[i];
}
memset(dp,0,sizeof dp);
int j ,i;
i = 1;
for( j = 1;j <= m&&i <= n;j ++){
dp[j] = max(dp[j-1] + a[i],dp[max(j-2,0ll)] + b[i]);
i++;
}
cout <<max(dp[j-1] ,dp[max(j-2,0ll)] )<<'\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 15088kb
input:
3 4 5 1 100 100 1 100 1 100 1 2 2 1 10 1 10 2 3 100 50 1 1000
output:
400 11 1000
result:
wrong answer 2nd numbers differ - expected: '2', found: '11'