Submission #363092

#TimeUsernameProblemLanguageResultExecution timeMemory
363092cpp219Holiday (IOI14_holiday)C++14
Compilation error
0 ms0 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 = 1e5 + 69; const ll mod = 1e9 + 7; typedef pair<ll,ll> LL; ll dp[3300][3300],a[N],n,start,d; ll Sub13(ll n,ll start,ll d,ll a[]){ multiset<ll> s; ll ans = 0,lf = start - 1,rg = n - start,cur = 0,x = start; for (ll i = 0;i <= lf;i++){ s.clear(); cur = 0; for (ll j = 0;j <= i;j++) cur += a[x - j],s.insert(a[x - j]); for (ll j = 0;j <= rg;j++){ ll rm = d - i - j - min(i,j); if (j != 0) s.insert(a[x + j]),cur += a[x + j]; if (rm <= 0) continue; while(s.size() > rm) cur -= *s.begin(),s.erase(s.begin()); //cout<<i<<" "<<j<<" "<<cur<<"\n"; ans = max(ans,cur); } } return ans; } ll Sub2(ll n,ll start,ll d,ll a[]){ priority_queue<ll> pq; ll cur = 0,ans = 0; for (ll i = 1;i <= n;i++){ pq.push(a[i]); cur += a[i]; ll rm = max(0ll,d - i - 1); while(pq.size() > rm){ cur -= pq.top(); pq.pop(); } ans = max(ans,cur); } return ans; } ll findMaxAttraction(ll n,ll start,ll d,ll a[]){ if (n <= 3000) return Sub13(n,start + 1,d,a); else if (start == 0) return Sub2(n,start + 1,d,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); } cin>>n>>start>>d; for (ll i = 1;i <= n;i++) cin>>a[i]; cout<<findMaxAttraction(n,start,d,a); } */

Compilation message (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 Sub13(long long int, long long int, long long int, long long int*)':
holiday.cpp:27:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |             while(s.size() > rm) cur -= *s.begin(),s.erase(s.begin());
      |                   ~~~~~~~~~^~~~
holiday.cpp: In function 'long long int Sub2(long long int, long long int, long long int, long long int*)':
holiday.cpp:41:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |         while(pq.size() > rm){
      |               ~~~~~~~~~~^~~~
holiday.cpp: In function 'long long int findMaxAttraction(long long int, long long int, long long int, long long int*)':
holiday.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
/tmp/ccVIG6OS.o: In function `main':
grader.cpp:(.text.startup+0x8c): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status