제출 #363632

#제출 시각아이디문제언어결과실행 시간메모리
363632cpp219휴가 (IOI14_holiday)C++14
23 / 100
65 ms25836 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 3e5 + 69; const ll mod = 1e9 + 7; typedef pair<ll,ll> LL; int val[2][N],n,start,d; struct Node{ ll val,on; }; Node st[4*N]; Node operator + (Node a,Node b){ Node c; c.val = a.val + b.val; c.on = a.on + b.on; return c; } void Renew(){ for (ll i = 1;i < 4*N;i++) st[i].val = st[i].on = 0; } void upd(ll id,ll l,ll r,ll u,ll val){ if (u < l||r < u) return; if (l == r){ st[id].val = val; st[id].on = 1; return; } ll mid = (l + r)/2; upd(id*2,l,mid,u,val); upd(id*2 + 1,mid + 1,r,u,val); st[id] = st[id*2] + st[id*2 + 1]; } ll Get(ll id,ll l,ll r,ll cnt){ if (st[id].on <= cnt) return st[id].val; ll mid = (l + r)/2; if (st[id*2].on > cnt) return Get(id*2,l,mid,cnt); else return st[id*2].val + Get(id*2 + 1,mid + 1,r,cnt - st[id*2].on); } ll cal(ll day,ll L,ll R,ll sz,ll a[]){ ll id[N]; LL A[N]; Renew(); for (ll i = 1;i <= sz;i++) A[i].fs = a[i],A[i].sc = i; sort(A + 1,A + sz + 1,greater<LL>()); for (ll i = 1;i <= sz;i++) id[A[i].sc] = i; ll mx = 0,ans; for (ll i = 1;i <= sz;i++){ ll rm = day - i + 1; if (rm <= 0) break; upd(1,1,sz,id[i],a[i]); ll p = Get(1,1,sz,rm); if (p > mx){ mx = p; ans = i; } } return mx; } ll findMaxAttraction(int n,int start,int d,int arr[]){ ll a[N]; for (ll i = 0;i < n;i++) a[i + 1] = arr[i]; //for (ll i = 1;i <= n;i++) a[i] = arr[i]; return cal(d,1,n,n,a); } /* int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); freopen(task".OUT","w",stdout); } int a[N]; cin>>n>>start>>d; for (ll i = 1;i <= n;i++) cin>>a[i]; cout<<findMaxAttraction(n,start,d,a); } */

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
holiday.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
holiday.cpp: In function 'long long int cal(long long int, long long int, long long int, long long int, long long int*)':
holiday.cpp:54:15: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   54 |     ll mx = 0,ans;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...