QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#166922 | #6868. Klee likes making friends | PPP# | WA | 371ms | 20012kb | C++17 | 1.3kb | 2023-09-06 21:01:02 | 2023-09-06 21:01:02 |
Judging History
answer
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
#define X first
#define Y second
ll pew(ll a, ll b)
{
ll res = 1;
while (b>0)
{
if (b&1) res = res*a%mod;
b >>= 1;
a = a*a%mod;
}
}
const int N = 2048;
int dp[N][N];
void solve()
{
for (int j=0;j<N;j++)
{
for (int i=0;i<N;i++) dp[j][i] = mod;
}
dp[0][1] = 0;
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i=0;i<n;i++) cin >> a[i];
int A = mod;
for (int i=0,i2=0;i<=n;i++,i2=(i2+1)%N)
{
if (i+k-1>=n) A = min(A,dp[i2][k-(n-i)-1]);
for (int d=1;d<k;d++)
{
dp[i2][d+1] = min(dp[i2][d+1],dp[i2][d]);
if ((i+k-d)>n) continue;
dp[(i2+k-d)%N][k-d] = min(dp[(i2+k-d)%N][k-d],dp[i2][d]+a[i+k-d-1]);
dp[i2][d] = mod;
}
}
cout << A << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//#ifdef DEBUG
// freopen("input.txt", "r", stdin);
//#endif
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 371ms
memory: 20012kb
input:
11 10 9 3 6 5 7 8 8 5 6 4 7 15 4 3034 6855 8797 12515 5315 13315 3021 5948 1618 5781 1305 4266 7634 8049 5990 15 2 6722 6887 1628 19483 16034 5800 2683 3444 10818 11900 13443 5020 11435 1033 4029 15 9 8450 8445 6959 2822 15741 16970 10576 13954 16766 12222 14601 10913 1683 16651 7250 381 30 17958 71...
output:
10 33346 120359 15081 55485 168329 114957 9386 7915 15308 12870
result:
wrong answer 1st lines differ - expected: '9', found: '10'