Submission #47240252


Source Code Expand

Copy
#include<bits/stdc++.h>
#define Withers using
#define AK namespace
#define IOI std
#define double long double
Withers AK IOI;typedef long long ll;typedef pair<int,int>pii;int n,m,u,v,w,x,y,z,l,r,minn=INT_MAX,maxx=INT_MIN,k;int tst;int a[200010];char s[200010];mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());char t[200010];
#define infll 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define endl '\n'
static char buf[1<<18],*paa=buf,*pddd=buf;static char buf2[1<<18],*pppp=buf2;
#define getchar()paa==pddd&&(pddd=(paa=buf)+fread(buf,1,1<<18,stdin),paa==pddd)?EOF:*paa++
inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define deb(x)cout<<#x<<"="<<x<<" ";
#define pb push_back
#define fi first
#define se second
#define mx3(a,b,c)((a>b?a:b)>c?(a>b?a:b):c)
#define mn3(a,b,c)((a<b?a:b)<c?(a<b?a:b):c)
#define mem(a,b)memset(a,b,sizeof(a))
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define Withers using
#define AK namespace
#define IOI std
#define double long double
Withers AK IOI;typedef long long ll;typedef pair<int,int>pii;int n,m,u,v,w,x,y,z,l,r,minn=INT_MAX,maxx=INT_MIN,k;int tst;int a[200010];char s[200010];mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());char t[200010];
#define infll 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define endl '\n'
static char buf[1<<18],*paa=buf,*pddd=buf;static char buf2[1<<18],*pppp=buf2;
#define getchar()paa==pddd&&(pddd=(paa=buf)+fread(buf,1,1<<18,stdin),paa==pddd)?EOF:*paa++
inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define deb(x)cout<<#x<<"="<<x<<" ";
#define pb push_back
#define fi first
#define se second
#define mx3(a,b,c)((a>b?a:b)>c?(a>b?a:b):c)
#define mn3(a,b,c)((a<b?a:b)<c?(a<b?a:b):c)
#define mem(a,b)memset(a,b,sizeof(a))
#define rep(i,a,b)for(int i=a;i<=b;i++)
double dp[5010][5010];
double pw[5010];
double pr[5010];
double mxx[5010];
void rd(int n,int a[]){for(int i=1;i<=n;i++)rd(a[i]);}void rda(){rd(n);for(int i=1;i<=n;i++)rd(a[i]);}void adde(vector<pii>g[],int x,int y,int z){g[x].push_back({y,z});g[y].push_back({x,z});}
int get(char s[]){char ch=' ';int cnt=0;int len=strlen(s+1);for(int i=1;i<=len;i++)s[i]=0;while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s[++cnt]=ch,ch=getchar();return cnt;}void put(char s[]){int len=strlen(s+1);for(int i=1;i<=len;i++)pc(s[i]);}void get(string&s){s="";char ch=' ';while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s.push_back(ch),ch=getchar();return;}void put(string s){int len=s.size();for(int i=0;i<len;i++)pc(s[i]);}
void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void solve()
{
	//do something
	rd(n);
	rep(i,1,n) rd(a[i]);
	pw[0]=1;pr[0]=1;
	rep(i,1,n) pw[i]=pw[i-1]*0.9,pr[i]=pr[i-1]+pw[i];
	//dpij now i(must) 
	double mx=0;
	double ans=-1e50;
	rep(i,0,n) mxx[i]=0;
	for(int i=n;i>=1;i--)
	{
		for(int j=n-i+1;j>=1;j--)
		{
			mx=mxx[j-1];
			mx+=pw[j-1]*a[i];
			dp[i][j]=mx;
			mxx[j]=max(mxx[j],mx);
			//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
			ans=max(ans,mx/pr[j-1]-1200.0/sqrtl(j));
		}
	}
	cout<<fixed<<setprecision(10)<<ans;
}
void multi()
{
	//rd(tst);
	tst=1;
	while(tst--)
	{
		solve();
	}
	pcc();
}
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	multi();
}
// POWERED BY WITHERS
// THINK ONCE, CODE TWICE
/*things to check
1.  int overflow or long long memory need
2.  recursion/array/binary search/dp/loop bounds
3.  precision
4.  special cases(n=1,bounds)
5.  delete debug statements
6.  initialize(especially multi-tests)
7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <= , - or =
8.  keep it simple and stupid
9.  do not delete, use // instead
10. operator priority
11. is there anything extra to output?
12. if you don't know where the bug is , try to clear some parts of the code
 and check each part seperately.
13. ...
*/
 
/* something to think about
1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
2. If contains "not", why not 正难则反 or few affect?
*/
// lgvc bilibilitdasc zxx zy graygoo tt cyx wsc akioi!

Submission Info

Submission Time
Task E - Maximize Rating
User Withers
Language C++ 20 (gcc 12.2)
Score 475
Code Size 3906 Byte
Status AC
Exec Time 168 ms
Memory 219000 KB

Compile Error

Main.cpp: In function ‘void rd(int&)’:
Main.cpp:12:199: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 | inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
      |                                                                                                                                                                                                       ^
Main.cpp:12:218: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 | inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
      |                                                                                                                                                                                                                          ^
Main.cpp: In function ‘void file(std::string)’:
Main.cpp:29:28: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 | void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:29:65: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 | void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3728 KB
example_01.txt AC 1 ms 3868 KB
example_02.txt AC 1 ms 3860 KB
hand_00.txt AC 167 ms 218844 KB
hand_01.txt AC 1 ms 3788 KB
hand_02.txt AC 167 ms 218992 KB
hand_03.txt AC 168 ms 218960 KB
hand_04.txt AC 1 ms 3716 KB
hand_05.txt AC 1 ms 3676 KB
hand_06.txt AC 168 ms 219000 KB
random_00.txt AC 167 ms 218172 KB
random_01.txt AC 161 ms 211272 KB
random_02.txt AC 5 ms 9356 KB
random_03.txt AC 1 ms 3784 KB
random_04.txt AC 1 ms 3672 KB
random_05.txt AC 167 ms 217788 KB
random_06.txt AC 164 ms 214344 KB
random_07.txt AC 4 ms 8256 KB
random_08.txt AC 1 ms 3968 KB
random_09.txt AC 1 ms 3812 KB
random_10.txt AC 164 ms 214972 KB
random_11.txt AC 163 ms 213568 KB
random_12.txt AC 4 ms 8628 KB
random_13.txt AC 1 ms 3980 KB
random_14.txt AC 1 ms 3876 KB
random_15.txt AC 161 ms 211936 KB
random_16.txt AC 166 ms 218836 KB
random_17.txt AC 5 ms 8968 KB
random_18.txt AC 1 ms 3860 KB
random_19.txt AC 1 ms 3760 KB
random_20.txt AC 164 ms 214292 KB
random_21.txt AC 162 ms 212800 KB
random_22.txt AC 4 ms 8572 KB
random_23.txt AC 1 ms 3856 KB
random_24.txt AC 1 ms 3864 KB


2025-03-05 (Wed)
18:10:01 +00:00