QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#22932 | #2884. 切切糕 | ha114514ha# | WA | 3ms | 5912kb | C++20 | 3.0kb | 2022-03-11 11:24:20 | 2022-04-30 02:08:42 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
// #pragma GCC optimize(3)
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace IO_BUFF{
mt19937 rnd(time(0)^(ll)(new char));
int rend(int x){
return rnd()%x+1;
}
void rendom_shuffle(int *a,int len){
shuffle(a+1,a+len+1,rnd);
}
const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
inline int gc(){
if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
return (HD==TL)?EOF:*HD++;
}
inline int inn(){
int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
}
char ssss[19999999],tttt[20];int ssl,ttl;
inline int print(int x)
{
if(x<0)ssss[++ssl]='-',x=(-x);
if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
}
inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
int read(){
char c=getchar();int x=1;int s=0;
while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
while(c>='0' && c<='9'){
s=s*10+c-'0';c=getchar();
}
return s*x;
}
}using namespace IO_BUFF;
/*namespace CFConTest{
const int mod=998244353;
inline int add(const int &x,const int &y){
return (x+y>=mod?x+y-mod:x+y);
}
inline int del(const int &x,const int &y){
return (x-y<0?x-y+mod:x-y);
}
int ksm(int x,int k){
int base=1;
while(k){
if(k&1)base=1ll*base*x%mod;
k>>=1;
x=1ll*x*x%mod;
}
return base;
}
};
using namespace CFConTest;*/
const int N=2005;
int n,m,a[N],s[N];
double f[N][N];
double dp(int x,int y){
if(f[x][y]!=-1)return f[x][y];
if(n-x+1==y){
return 1.0*s[x]/2;
}
if(!y){
return s[x];
}
double kx=dp(x+1,y-1);
double ky=dp(x+1,y);
double ans=0;
if(ky+a[x]<=kx){
ans=ky+a[x];
}
else {
ans=kx+1.0*(a[x]-kx+ky)/2.0;
}
f[x][y]=ans;
return f[x][y];
}
int main(){
#ifdef newbiewzs
freopen("data.in","r",stdin);
#else
#endif
n=read();m=read();
for(int i=1;i<=n;i++)a[i]=read();
for(int i=1;i<=n;i++)for(int k=0;k<=n;k++)f[i][k]=-1;
sort(a+1,a+n+1);
for(int i=n;i>=1;i--)s[i]=s[i+1]+a[i];
printf("%.10lf",dp(1,m));
#ifdef newbiewzs
cerr<<'\n'<<"Time:"<<clock()<<" ms"<<'\n';
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 5912kb
input:
1 1 10
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5680kb
input:
10 8 1 2 3 1 2 2 1 3 3 2
output:
10.0351562500
result:
ok found '10.0351562', expected '10.0351562', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 5724kb
input:
2500 1 1 1 2 1 4 1 5 1 2 2 3 4 2 3 4 3 4 1 4 5 3 5 4 4 1 3 3 3 5 5 5 3 2 2 3 2 3 2 1 1 5 4 2 1 3 4 3 4 2 3 1 1 2 2 2 4 3 1 1 4 2 2 4 3 5 4 2 3 1 1 4 3 3 4 3 1 2 1 1 2 2 4 4 3 3 2 5 4 2 4 5 4 5 3 1 5 1 3 3 1 1 3 5 3 5 1 1 4 3 5 2 4 1 5 2 1 3 3 1 1 5 2 1 3 4 1 2 4 2 2 2 3 5 1 1 3 1 1 5 1 2 3 3 5 4 4 5...
output:
4.5000000000
result:
wrong answer 1st numbers differ - expected: '7442.0000000', found: '4.5000000', error = '0.9993953'