QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#469628 | #8008. Fortune Wheel | maojun | WA | 0ms | 4188kb | C++23 | 601b | 2024-07-09 21:17:56 | 2024-07-09 21:17:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,x,m,k[505],dis[N];
int main(){
scanf("%d%d%d",&n,&x,&m);
for(int i=1;i<=m;i++)scanf("%d",&k[i]);
queue<int>q;memset(dis,0xff,sizeof dis);dis[0]=0;q.push(0);
while(!q.empty()){
int u=q.front();q.pop();
for(int i=1;i<=m;i++){
int v=(u+n-k[i])%n;
if(!~dis[v]){dis[v]=dis[u]+1;q.push(v);}
}
}
ll ax=~dis[x]?dis[x]:1e12,ay=1,sum=n;
sort(dis,dis+n);
for(int i=1;i<=n;i++){
sum+=dis[i-1];
if(ax*i>sum*ay){ax=sum;ay=i;}
}
printf("%lld %lld\n",ax,ay);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4188kb
input:
6 3 2 2 4
output:
3 4
result:
wrong answer 1st numbers differ - expected: '8', found: '3'