Submission #522961

#TimeUsernameProblemLanguageResultExecution timeMemory
522961ftkbrianHoliday (IOI14_holiday)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define pll pair<ll,ll> #define f first #define s second bool offline; ll n,d; ll A[101010]; vector<ll> V; ll idx(ll v) { return lower_bound(V.begin(),V.end(),v)-V.begin()+1; } pll ST[404040]; pll hap(pll a,pll b) { return {a.f+b.f,a.s+b.s}; } void upd(ll id,ll s,ll e,ll t,ll v) { if(s > t || t > e) return; if(s == e) { ST[id].f += v; ST[id].s++; return; } ll m = s+e>>1; upd(id*2,s,m,t,v); upd(id*2+1,m+1,e,t,v); ST[id] = hap(ST[id*2],ST[id*2+1]); } ll query(ll id,ll s,ll e,ll lft) { if(s == e) { if(ST[id].s == 0) return 0; return ST[id].f/ST[id].s*min(ST[id].s,lft); } ll m = s+e>>1; if(ST[id*2+1].s < lft) return ST[id*2+1].f+query(id*2,s,m,lft-ST[id*2+1].s); return query(id*2+1,m+1,e,lft); } ll st;///시작점 ll ans; ll dist(ll a,ll b,ll c) { return c-a+max(0ll,min(c-b,b-a)); } void DnC(ll s,ll e,ll qs,ll qe) { if(s > e) return; ll m = s+e>>1; V.clear(); ll opt = qs,val = -1; for(int i = m ; i <= qe ; i++) { if(dist(m,st,i) > d) break; V.push_back(A[i]); } sort(V.begin(),V.end()); V.erase(unique(V.begin(),V.end()),V.end()); ll sz = V.size(); for(int i = 1 ; i <= 4*sz ; i++) ST[i] = {0,0}; for(int i = m ; i < qs ; i++) upd(1,1,sz,idx(A[i]),A[i]); for(int i = qs ; i <= qe ; i++) { ll v = d-dist(m,st,i); if(v <= 0) break; upd(1,1,sz,idx(A[i]),A[i]); ll vl = query(1,1,sz,v); if(val < vl) opt = i,val = vl; } ans = max(ans,val); DnC(s,m-1,qs,opt); DnC(m+1,e,opt,qe); } main() { if(offline) freopen("input.txt","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin>>n>>st>>d; st++; for(int i = 1 ; i <= n ; i++) cin>>A[i]; DnC(1,st,st,n); cout<<ans<<"\n"; }

Compilation message (stderr)

holiday.cpp: In function 'void upd(ll, ll, ll, ll, ll)':
holiday.cpp:19:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |  ll m = s+e>>1;
      |          ^
holiday.cpp: In function 'll query(ll, ll, ll, ll)':
holiday.cpp:28:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |  ll m = s+e>>1;
      |          ^
holiday.cpp: In function 'void DnC(ll, ll, ll, ll)':
holiday.cpp:40:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |  ll m = s+e>>1; V.clear();
      |          ^
holiday.cpp: At global scope:
holiday.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
holiday.cpp: In function 'int main()':
holiday.cpp:63:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  if(offline) freopen("input.txt","r",stdin);
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3zzetv.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqWwgit.o:holiday.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3zzetv.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status