# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
552589 | 2022-04-23T11:33:11 Z | mars4 | Lightning Conductor (POI11_pio) | C++17 | 159 ms | 25288 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; void calc(ll l,ll r,ll optL,ll optR) { if(l>r) { return; } ll mid=(l+r)>>1; pair<ld,ll> best={LLONG_MIN,-1}; for(ll i=optL;i<=min(mid,optR);i++) { ld p=(ld)a[i]+sq[mid-i]; if(p>best.ff) { best={p,i}; } } ll opt=best.ss; ans[mid]=max(ans[mid],a[opt]-a[mid]+(ll)ceil(sq[mid-opt])); 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 2860 KB | Output is correct |
2 | Correct | 18 ms | 2660 KB | Output is correct |
3 | Correct | 16 ms | 3120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 4428 KB | Output is correct |
2 | Correct | 28 ms | 4344 KB | Output is correct |
3 | Correct | 37 ms | 4540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 10392 KB | Output is correct |
2 | Correct | 64 ms | 9956 KB | Output is correct |
3 | Correct | 66 ms | 9992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 109 ms | 17868 KB | Output is correct |
2 | Correct | 97 ms | 15752 KB | Output is correct |
3 | Correct | 114 ms | 16512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 157 ms | 25288 KB | Output is correct |
2 | Correct | 148 ms | 22452 KB | Output is correct |
3 | Correct | 141 ms | 23500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 22904 KB | Output is correct |
2 | Correct | 146 ms | 22476 KB | Output is correct |
3 | Correct | 139 ms | 23476 KB | Output is correct |