QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#703368 | #7159. Candy | sususy | 6 | 32ms | 12320kb | C++14 | 767b | 2024-11-02 17:40:04 | 2024-11-02 17:40:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 102;
ll n, k, l;
ll f[2][N][N * (N + 1) / 2];
ll a[N];
int main()
{
scanf("%lld%lld%lld", &n, &k, &l);
for(ll i = 1; i <= n; i++)
scanf("%lld", &a[i]);
ll ans = 0x3f3f3f3f3f3f3f3fll;
for(ll i = 1; i <= n; i++)
{
memcpy(f[i & 1], f[(i & 1) ^ 1], sizeof(f[i & 1]));
for(ll j = 0; j < k && j < i; j++)
{
for(ll cnt = 0; cnt <= (i - j - 1) * j; cnt++)
{
f[i & 1][j + 1][cnt + i - j - 1] = max(f[i & 1][j][cnt], f[(i & 1) ^ 1][j][cnt] + a[i]);
if(f[i & 1][j + 1][cnt + i - j - 1] >= l)
ans = min(ans, cnt + i - j - 1);
}
}
}
if(ans == 0x3f3f3f3f3f3f3f3fll)
puts("NO");
else
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 0ms
memory: 8940kb
input:
1 1 7 7
output:
0
result:
ok single line: '0'
Test #2:
score: 6
Accepted
time: 0ms
memory: 8116kb
input:
1 1 8 7
output:
NO
result:
ok single line: 'NO'
Test #3:
score: 6
Accepted
time: 0ms
memory: 12040kb
input:
2 1 7 5 6
output:
NO
result:
ok single line: 'NO'
Test #4:
score: 6
Accepted
time: 0ms
memory: 12288kb
input:
2 1 7 7 9
output:
0
result:
ok single line: '0'
Test #5:
score: 6
Accepted
time: 0ms
memory: 12160kb
input:
2 1 7 5 7
output:
1
result:
ok single line: '1'
Test #6:
score: 6
Accepted
time: 3ms
memory: 12108kb
input:
2 2 7 2 4
output:
NO
result:
ok single line: 'NO'
Test #7:
score: 6
Accepted
time: 0ms
memory: 12252kb
input:
2 2 7 3 4
output:
0
result:
ok single line: '0'
Test #8:
score: 6
Accepted
time: 0ms
memory: 9976kb
input:
1 1 100 100
output:
0
result:
ok single line: '0'
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 32ms
memory: 12244kb
input:
100 50 50 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
2305
result:
wrong answer 1st lines differ - expected: '1805', found: '2305'
Subtask #3:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #24:
score: 16
Accepted
time: 2ms
memory: 9432kb
input:
1 1 7 7
output:
0
result:
ok single line: '0'
Test #25:
score: 16
Accepted
time: 1ms
memory: 9032kb
input:
1 1 8 7
output:
NO
result:
ok single line: 'NO'
Test #26:
score: 16
Accepted
time: 2ms
memory: 12188kb
input:
2 1 7 5 6
output:
NO
result:
ok single line: 'NO'
Test #27:
score: 16
Accepted
time: 4ms
memory: 12232kb
input:
2 1 7 7 9
output:
0
result:
ok single line: '0'
Test #28:
score: 16
Accepted
time: 4ms
memory: 12256kb
input:
2 1 7 5 7
output:
1
result:
ok single line: '1'
Test #29:
score: 16
Accepted
time: 3ms
memory: 12112kb
input:
2 2 7 2 4
output:
NO
result:
ok single line: 'NO'
Test #30:
score: 16
Accepted
time: 3ms
memory: 12260kb
input:
2 2 7 3 4
output:
0
result:
ok single line: '0'
Test #31:
score: 16
Accepted
time: 3ms
memory: 12132kb
input:
3 1 7 4 5 6
output:
NO
result:
ok single line: 'NO'
Test #32:
score: 16
Accepted
time: 4ms
memory: 12316kb
input:
3 1 7 4 5 7
output:
2
result:
ok single line: '2'
Test #33:
score: 16
Accepted
time: 4ms
memory: 12172kb
input:
3 1 7 4 8 7
output:
1
result:
ok single line: '1'
Test #34:
score: 16
Accepted
time: 0ms
memory: 12216kb
input:
3 1 7 7 3 9
output:
0
result:
ok single line: '0'
Test #35:
score: 16
Accepted
time: 3ms
memory: 12124kb
input:
3 2 7 3 3 3
output:
NO
result:
ok single line: 'NO'
Test #36:
score: 16
Accepted
time: 0ms
memory: 12248kb
input:
3 2 7 2 3 4
output:
2
result:
ok single line: '2'
Test #37:
score: 16
Accepted
time: 0ms
memory: 12124kb
input:
3 2 7 3 2 4
output:
1
result:
ok single line: '1'
Test #38:
score: 16
Accepted
time: 0ms
memory: 12284kb
input:
3 2 7 4 5 6
output:
0
result:
ok single line: '0'
Test #39:
score: 16
Accepted
time: 3ms
memory: 12096kb
input:
3 3 7 1 3 2
output:
NO
result:
ok single line: 'NO'
Test #40:
score: 16
Accepted
time: 0ms
memory: 12240kb
input:
3 3 7 3 1 3
output:
0
result:
ok single line: '0'
Test #41:
score: 16
Accepted
time: 0ms
memory: 12128kb
input:
3 2 0 0 0 0
output:
0
result:
ok single line: '0'
Test #42:
score: 16
Accepted
time: 0ms
memory: 12316kb
input:
3 2 0 1 2 3
output:
0
result:
ok single line: '0'
Test #43:
score: 16
Accepted
time: 4ms
memory: 12168kb
input:
20 10 6566144533 323906753 73234 169258261 146483217 2526483 50563297 7173957 419870302 86885946 277634715 748939350 422834669 440114820 504900304 648304476 630339210 900877811 593594945 953548400 722690548
output:
100
result:
ok single line: '100'
Test #44:
score: 16
Accepted
time: 4ms
memory: 12320kb
input:
20 10 6164244072 155183169 228236990 208003086 343519393 203430078 129307145 158643368 33100189 235687056 222657550 413967161 896436020 887689465 550380926 691043319 946504501 444961305 475841383 388568669 468851323
output:
100
result:
ok single line: '100'
Test #45:
score: 16
Accepted
time: 8ms
memory: 12164kb
input:
20 18 9610913809 58382570 1322710 654840381 202842775 300914313 462981306 141101410 670033653 737028856 888310178 420221248 393987230 214258398 897791395 261977352 762131762 938005468 558347054 363867624 742273406
output:
36
result:
ok single line: '36'
Test #46:
score: 0
Wrong Answer
time: 4ms
memory: 12040kb
input:
20 8 8000000000 1000000000 999999999 1000000000 1000000000 999999999 999999999 999999999 1000000000 1000000000 999999999 1000000000 1000000000 999999999 999999999 999999999 1000000000 999999999 1000000000 999999999 1000000000
output:
NO
result:
wrong answer 1st lines differ - expected: '28', found: 'NO'
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%