QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#439210 | #6369. Frog Jumping | moyujiang | WA | 0ms | 3956kb | C++14 | 919b | 2024-06-11 18:08:59 | 2024-06-11 18:08:59 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a),i##END=(b);i<=i##END;i++)
#define Rof(i,b,a) for(int i=(b),i##END=(a);i>=i##END;i--)
#define go(u) for(int i=head[u];i;i=nxt[i])
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
const int N=1e5+10;
int n,m,k,d,c[N],a[N],ans;
signed main(){
n=read(),m=read(),k=read(),d=read();
if(d>=n)return puts("0"),0;
For(i,1,m)c[i]=read();
For(i,1,k)a[i]=read();a[0]=1,a[k+1]=n;
sort(a+1,a+1+k);
int mn=m,l=0;For(r,1,k){
while(a[r]-a[l]>d)l++;
if(l>0)mn=min(mn,r-l+1);
}For(i,0,k)if(a[i+1]-a[i]>d)mn=0;
sort(c+1,c+1+m);For(i,1,m-mn)ans+=c[i];
if(mn==0){ans-=c[1];For(i,0,k)ans+=c[1]*(a[i+1]-a[i]>d);}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3956kb
input:
10 2 3 3 4 7 4 8 7
output:
0
result:
wrong answer 1st numbers differ - expected: '4', found: '0'