Submission #552573

# Submission time Handle Problem Language Result Execution time Memory
552573 2022-04-23T10:23:45 Z mars4 Lightning Conductor (POI11_pio) C++17
27 / 100
1000 ms 16332 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define i128            __int128_t
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod         1'000'000'007
#define mod2        998'244'353 
#define inf         1'000'000'000'000'007
#define pi          3.14159265358979323846

template<class key,class cmp=std::less<key>>
using ordered_set=tree<key,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class T> ostream& operator<<(ostream& out,ordered_set<T> &s)           {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

//---------------------------------mars4---------------------------------

vector<ll> a;
vector<ld> sq;
vector<ll> ans;

ll val(ll hi,ll hj,ll i,ll j)
{
	return hj-hi+(ll)ceill(sq[i-j]);
};

void calc(ll l,ll r,ll optL,ll optR)
{
	if(l>r)
	{
		return;
	}
	ll mid=(l+r)>>1;
	pair<ll,ll> best={LLONG_MIN,-1};
	for(ll i=optL;i<=min(mid,optR);i++)
	{
		ll p=val(a[mid],a[i],mid,i);
		if(p>best.ff)
		{
			best={p,i};
		}
	}
	ans[mid]=max(ans[mid],best.ff);
	ll opt=best.ss;
	calc(l,mid-1,optL,opt);
	calc(mid+1,r,opt,optR);
}

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	a=vector<ll>(n);
	sq=vector<ld>(n);
	ans=vector<ll>(n);
	for(ll &i:a)
	{
		cin>>i;
	}
	forn(i,0,n)
	{
		sq[i]=sqrtl(i);
	}
	forn(k,0,2)
	{
		calc(0,n-1,0,n-1);
		reverse(all(a));
		reverse(all(ans));
	}
	for(ll i:ans)
	{
		cout<<i<<"\n";
	}
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}

Compilation message

pio.cpp: In function 'int main()':
pio.cpp:80:5: warning: unused variable 'z' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |     ^
pio.cpp:80:9: warning: unused variable 'm' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |         ^
pio.cpp:80:11: warning: unused variable 't' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |           ^
pio.cpp:80:13: warning: unused variable 'k' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |             ^
pio.cpp:80:15: warning: unused variable 'i' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |               ^
pio.cpp:80:17: warning: unused variable 'j' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |                 ^
pio.cpp:80:19: warning: unused variable 'l' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |                   ^
pio.cpp:80:21: warning: unused variable 'd' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |                     ^
pio.cpp:80:23: warning: unused variable 'h' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |                       ^
pio.cpp:80:25: warning: unused variable 'r' [-Wunused-variable]
   80 |  ll z,n,m,t,k,i,j,l,d,h,r;
      |                         ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 88 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 224 ms 2728 KB Output is correct
2 Correct 205 ms 2740 KB Output is correct
3 Incorrect 212 ms 2988 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 340 ms 4176 KB Output is correct
2 Correct 323 ms 4172 KB Output is correct
3 Incorrect 326 ms 4464 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 814 ms 8920 KB Output is correct
2 Correct 823 ms 8780 KB Output is correct
3 Incorrect 824 ms 9416 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 11672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 16304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 16332 KB Time limit exceeded
2 Halted 0 ms 0 KB -