QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528606 | #2784. Aliens | xyz123# | 0 | 2ms | 10272kb | C++23 | 1.8kb | 2024-08-23 16:48:01 | 2024-08-23 16:48:01 |
Judging History
answer
#include "aliens.h"
#include<bits/stdc++.h>
using namespace std;
long long dp[1000001],a,b,cn,g[1000001],f[1000001];
struct p{long long q,w;}l[1000001],m[1000001];
bool cmp(p qq,p ww){if(qq.q==ww.q) return qq.w>ww.w;return qq.q<ww.q;}
void ch(long long qq)
{
dp[0]=0,g[0]=0;
for(int i=1;i<=b;i++)
{
dp[i]=1e18,g[i]=0;
for(int j=0;j<i;j++)
{
long long tt=dp[j]+(m[i].w+1-m[j+1].q)*(m[i].w+1-m[j+1].q)-f[j]+qq;
// cout<<tt<<" "<<dp[j]<<" "<<f[j]<<"\n";
if(tt<dp[i]) dp[i]=tt,g[i]=g[j]+1;
else if(tt==dp[i]&&g[j]+1<g[i]) dp[i]=tt,g[i]=g[j]+1;
}
}
// cout<<qq<<" "<<dp[b]<<" "<<g[b]<<"\n";
}
long long take_photos(int n, int mm, int k, std::vector<int> r, std::vector<int> c) {
a=n,b=mm;
swap(a,b);
long long ll=0,rr=1e12;
for(int i=0;i<b;i++)
{
if(r[i]<c[i]) l[i+1]=p{r[i]+1,c[i]+1};
else l[i+1]=p{c[i]+1,r[i]+1};
}
sort(l+1,l+b+1,cmp);
long long mxx=0;
for(int i=1;i<=b;i++)
{
// cout<<l[i].q<<" "<<l[i].w<<"\n";
if(cn>0&&m[cn].w>=l[i].w) continue;
else m[++cn]=l[i];
}b=cn;
for(int i=1;i<b;i++)
{
if(m[i].w>=m[i+1].q) f[i]=(m[i].w-m[i+1].q+1)*(m[i].w-m[i+1].q+1);
assert(f[i]==0);
assert(m[i].q!=m[i-1].q);
}
// cout<<b<<"\n";
// for(int i=1;i<=b;i++) cout<<m[i].q<<" "<<m[i].w<<"\n";
// exit(0);
long long ann=0;
while(ll<=rr)
{
long long mid=((ll+rr)>>1);
ch(mid);
if(g[b]<=k) ann=mid,rr=mid-1;
else ll=mid+1;
}
ch(ann);
return dp[b]-g[b]*ann;
}
//int main() {
// int n, m, k;
// assert(3 == scanf("%d %d %d", &n, &m, &k));
// std::vector<int> r(n), c(n);
// for (int i = 0; i < n; i++) {
// assert(2 == scanf("%d %d", &r[i], &c[i]));
// }
// long long ans = take_photos(n, m, k, r, c);
//
//
// printf("%lld\n", ans);
// return 0;
//}
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 4
Accepted
time: 1ms
memory: 9920kb
input:
2 6 2 1 4 4 1
output:
098d134608c94f7413faac591054ee35 16
result:
ok Correct answer: answer = 16
Test #2:
score: 4
Accepted
time: 1ms
memory: 10044kb
input:
1 2 1 0 1
output:
098d134608c94f7413faac591054ee35 4
result:
ok Correct answer: answer = 4
Test #3:
score: 4
Accepted
time: 0ms
memory: 9968kb
input:
2 2 2 0 0 1 0
output:
098d134608c94f7413faac591054ee35 4
result:
ok Correct answer: answer = 4
Test #4:
score: 4
Accepted
time: 1ms
memory: 9972kb
input:
2 3 2 0 1 1 1
output:
098d134608c94f7413faac591054ee35 4
result:
ok Correct answer: answer = 4
Test #5:
score: 0
Runtime Error
input:
4 4 4 1 3 0 1 2 1 2 2
output:
Unauthorized output
result:
Subtask #2:
score: 0
Wrong Answer
Test #23:
score: 12
Accepted
time: 1ms
memory: 9892kb
input:
2 2 1 0 0 1 1
output:
098d134608c94f7413faac591054ee35 4
result:
ok Correct answer: answer = 4
Test #24:
score: 12
Accepted
time: 1ms
memory: 10000kb
input:
4 3 2 0 0 0 0 0 0 0 0
output:
098d134608c94f7413faac591054ee35 1
result:
ok Correct answer: answer = 1
Test #25:
score: 12
Accepted
time: 0ms
memory: 9932kb
input:
5 5 2 2 2 3 3 4 4 3 3 3 3
output:
098d134608c94f7413faac591054ee35 5
result:
ok Correct answer: answer = 5
Test #26:
score: 12
Accepted
time: 1ms
memory: 9956kb
input:
10 20 3 3 3 15 15 10 10 18 18 4 4 7 7 15 15 2 2 10 10 7 7
output:
098d134608c94f7413faac591054ee35 41
result:
ok Correct answer: answer = 41
Test #27:
score: 12
Accepted
time: 1ms
memory: 9960kb
input:
20 1000 5 737 737 714 714 662 662 163 163 683 683 615 615 23 23 246 246 724 724 90 90 802 802 557 557 146 146 429 429 816 816 164 164 638 638 568 568 957 957 904 904
output:
098d134608c94f7413faac591054ee35 71923
result:
ok Correct answer: answer = 71923
Test #28:
score: 12
Accepted
time: 2ms
memory: 9968kb
input:
200 1000 10 69 69 277 277 350 350 753 753 741 741 849 849 993 993 95 95 928 928 789 789 333 333 795 795 493 493 253 253 661 661 780 780 17 17 394 394 487 487 719 719 426 426 297 297 885 885 323 323 981 981 916 916 0 0 997 997 757 757 374 374 467 467 787 787 297 297 216 216 599 599 62 62 936 936 777 ...
output:
098d134608c94f7413faac591054ee35 77137
result:
ok Correct answer: answer = 77137
Test #29:
score: 0
Wrong Answer
time: 2ms
memory: 10272kb
input:
500 1000 250 599 599 14 14 176 176 963 963 93 93 257 257 403 403 741 741 854 854 862 862 778 778 489 489 711 711 623 623 163 163 750 750 649 649 441 441 245 245 311 311 429 429 756 756 572 572 766 766 837 837 137 137 719 719 244 244 519 519 287 287 251 251 818 818 789 789 305 305 400 400 262 262 359...
output:
098d134608c94f7413faac591054ee35 925
result:
wrong answer Wrong answer: output = 925, expected = 764
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%