QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377912 | #8524. Weather Forecast | Days_of_Future_Past# | Compile Error | / | / | C++23 | 1.7kb | 2024-04-05 20:10:09 | 2024-04-05 20:10:09 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define mp make_pair
#define N 310000
#define inf 1000000007
using namespace std;
int n,k;
int a[N],id[N];
long double b[N];
int f[N];
int st[N];
int lowbit(int x)
{
return x & (-x);
}
void insert(int x,int y)
{
//cout<<x<<endl;
while (x<=n)
{
st[x]=max(st[x],y);
x+=lowbit(x);
}
}
int get(int x)
{
//cout<<x<<endl;
int ret=0;
while (x)
{
ret=max(ret,st[x]);
x-=lowbit(x);
}
return ret;
}
bool check(long double ave)
{
rep(i,n)b[i]=b[i-1]+a[i]-ave;
if (b[n]<0)return 0;
vector<long double> save; save.clear();
rep(i,n)save.pb(b[i]);
//rep(i,n)cout<<b[i]<<" "; puts("");
sort(save.begin(),save.end());
save.resize(unique(save.begin(),save.end())-save.begin());
rep(i,n)st[i]=0;
rep(i,n)
{
int x=lower_bound(save.begin(),save.end(),b[i])-save.begin()+1;
//cout<<x<<endl;
int t=get(x);
f[i]=0;
if (t==0)if (b[i]>=0)f[i]=1;
if (t!=0)f[i]=t+1;
insert(x,f[i]);
}
//cout<<f[n]<<endl;
return f[n]>=k;
}
int main()
{
cin>>n>>k;
rep(i,n)scanf("%d",&a[i]);
long double l=0,r=1000;
for(int ti=1;ti<=50;ti++)
{
long double mid=(l+r)/2;
//cout<<mid<<endl;
if (check(mid))l=mid; else r=mid;
}
printf("%.10Lf\n",l);
//cout<<check(1.713)<<endl;
//cout<<check(0)<<endl;
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:67:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | rep(i,n)scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:4: /usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Vector_base<long double, std::allocator<long double> >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long double]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/functional:64, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~