QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#631894 | #9450. Balloon Robot | ucup-team1004# | AC ✓ | 140ms | 8004kb | C++17 | 973b | 2024-10-12 10:50:42 | 2024-10-14 16:41:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=5e5+10;
int T,n,m,k,a[N],b[N];
ll c[N];
void get(){
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]--;
for(int x,y,i=1;i<=k;i++){
scanf("%d%d",&x,&y),b[i]=(a[x]-y%m+m)%m;
}
copy(b,b+1+k,a);
sort(a+1,a+1+k),n=unique(a+1,a+1+k)-a-1;
for(int i=1;i<=k;i++){
int x=lower_bound(a+1,a+1+n,b[i])-a;
c[n]+=m+b[i],c[x]-=m;
}
for(int i=n;i>1;i--)c[i-1]+=c[i];
ll ans=LLONG_MAX;
for(int i=1;i<=n;i++){
ans=min(ans,c[i]-1ll*k*a[i]);
}
printf("%lld\n",ans);
}
void clr(){
for(int i=0;i<=k+1;i++)c[i]=0;
}
int main(){
for(scanf("%d",&T);T--;clr())get();
return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 8004kb
input:
4 2 3 3 1 2 1 1 2 1 1 4 2 3 5 1 2 1 1 2 1 1 2 1 3 1 4 3 7 5 3 5 7 1 5 2 1 3 3 1 5 2 5 2 100 2 1 51 1 500 2 1000
output:
1 4 5 50
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 140ms
memory: 6996kb
input:
1004 22 9426 26 1165 5248 8331 9055 1161 7381 2188 7489 5131 8434 2166 3981 6302 7188 4858 856 7797 9129 7839 1676 25 9053 20 6 22 68 12 16 11 63 17 49 5 10 21 68 17 80 18 18 10 28 15 55 14 80 1 45 21 67 5 74 13 4 3 34 7 80 9 95 5 52 8 31 2 53 7 22 5 99 20 66 12 2 33 9526 92 558 7460 280 7952 5186 9...
output:
94067 360219 223074 30971 171844 312753 0 158169 294738 291604 115632 59327 221328 287851 30518 337118 181724 249419 66367 10347 208411 180496 287130 40736 264604 278208 33792 191523 111583 31867 21143 232153 149868 191831 238832 63626 258936 133059 105618 237774 53942 342921 275883 110295 149350 20...
result:
ok 1004 lines
Extra Test:
score: 0
Extra Test Passed