QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858543 | #9676. Ancestors | J_R_X | 0 | 402ms | 7672kb | C++14 | 592b | 2025-01-16 18:49:03 | 2025-01-16 18:49:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int f[1005][1005];
void solve() {
int a,b; cin>>a>>b;
cout<<f[a][b]<<'\n';
return ;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
f[2][0]=1;
f[2][1]=3;
for(int i=2;i<=1000;i++) f[2][i]=f[2][i-1]+i+1;
for(int i=3;i<=1000;i++) {
f[i][1]=2;
for(int j=2;j<=1000;j++) {
f[i][j]=1e9;
for(int k=1;k<=j;k++) f[i][j]=min(f[i][j],f[i-1][j-k]+k*(k+1)/2);
}
}
int t; cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 402ms
memory: 7672kb
input:
7 5 3 1 0 5 3 5 1 1 3 1 5 7 2 1 5 1 4 7 1 4 7 2
output:
4 0 4 2 0 0 3
result:
wrong answer 1st numbers differ - expected: '2', found: '4'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Runtime Error
Test #30:
score: 0
Runtime Error
input:
50000 200000 42574 43129 47328 17982 40521 6668 12729 32377 201 11940 8599 11734 18349 41045 26854 22540 9897 33419 7463 1243 47272 27135 49050 49111 22435 42539 39924 20272 5843 9308 45963 3283 31185 13692 38952 20583 15885 24802 4773 953 49907 28689 36942 23550 19449 8970 33340 31665 5407 46023 18...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Runtime Error
Test #67:
score: 0
Runtime Error
input:
100000 1000000 6457 23693 90928 23592 90440 75018 16865 3342 83718 16731 95103 31510 38719 27886 29093 41955 6596 46409 51839 10527 91993 61074 14405 34833 53674 42363 11490 43757 46191 6058 59164 96938 57858 40178 97523 84164 21582 72243 11267 47368 97058 6637 95208 60092 53943 16441 28363 64965 52...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%