Submission #853034

#TimeUsernameProblemLanguageResultExecution timeMemory
853034onepunchac168Holiday (IOI14_holiday)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define task "STOUR" #define fi first #define se second #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; const char nl='\n'; void onepunchac168(); signed main() { ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } onepunchac168(); } ll n,s,d; const int N=1e5+5; ll a[N]; void sub1() { priority_queue<ll,vector <ll> ,greater <ll> > qu; ll res=0; ll sum=0; for (int i=1;i<=n;i++) { qu.push(a[i]); sum+=a[i]; while (qu.size()>d-i+1) { sum-=qu.top(); qu.pop(); } res=max(res,sum); } cout<<res; } const int M=3e3+5; void sub2() { ll res=0; for (int i=1;i<=s;i++) { priority_queue<ll,vector <ll> ,greater <ll> > qu; ll sum=0; for (int j=i;j<=n;j++) { qu.push(a[j]); sum+=a[j]; if (j>=s) { ll pp=(s-i)+(j-s)+min(s-i,j-s); while (qu.size()>d-pp) { sum-=qu.top(); qu.pop(); } res=max(res,sum); } } } cout<<res; } void onepunchac168() { cin>>n>>s>>d; s++; for (int i=1;i<=n;i++) { cin>>a[i]; } if (s==1) { sub1(); } else sub2(); }

Compilation message (stderr)

holiday.cpp: In function 'void sub1()':
holiday.cpp:39:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   39 |         while (qu.size()>d-i+1)
      |                ~~~~~~~~~^~~~~~
holiday.cpp: In function 'void sub2()':
holiday.cpp:65:33: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   65 |                 while (qu.size()>d-pp)
      |                        ~~~~~~~~~^~~~~
holiday.cpp: In function 'int main()':
holiday.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
holiday.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccBlqQF7.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccE8NSZ8.o:holiday.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccBlqQF7.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status