QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22930 | #2884. 切切糕 | hy_zheng_zai_nei_juan# | WA | 11ms | 74912kb | C++20 | 1.7kb | 2022-03-11 11:19:07 | 2022-04-30 02:08:36 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
#define BUF_SIZE 100000
bool IOerror=0;
inline char nc()
{
static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
if (p1==pend){
p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
if (pend==p1){IOerror=1;return -1;}
}
return *p1++;
}
inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
inline ll read()
{
bool sign=0; char ch=nc();ll x=0;
for (;blank(ch);ch=nc());
if (IOerror)return 0;
if (ch=='-')sign=1,ch=nc();
for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
if (sign)x=-x;
return x;
}
#undef BUF_SIZE
};
using namespace fastIO;
int a[1000010];
double f[3010][3010];
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int n=qr,m=qr;
for(int i=1;i<=n;i++)in(a[i]);
memset(f,128,sizeof(f));
f[0][m]=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=m;j++)
{
if(j==m)f[i][j]=f[i-1][j]+a[i];
else
{
if(f[i-1][j+1]>=f[i-1][j]+a[i])f[i][j]=f[i-1][j+1];
else f[i][j]=(f[i][j],(f[i-1][j+1]+f[i-1][j]+a[i])/2);
}
}
}
double ans=1e16;
for(int i=0;i<=m;i++)ans=min(ans,f[n][i]);
printf("%.6f",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 11ms
memory: 74596kb
input:
1 1 10
output:
5.000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 74912kb
input:
10 8 1 2 3 1 2 2 1 3 3 2
output:
10.013672
result:
wrong answer 1st numbers differ - expected: '10.0351562', found: '10.0136720', error = '0.0021409'