Submission #432787

#TimeUsernameProblemLanguageResultExecution timeMemory
432787REALITYNBHoliday (IOI14_holiday)C++17
0 / 100
5054 ms6212 KiB
#include <bits/stdc++.h> #include "holiday.h" using namespace std; long long findMaxAttraction(int n , int start , int d , int* a){ #define int long long int ans = 0 ; for(int i=start;i<n;i++){ multiset<int> el ; for(int j=start;j<=i;j++) el.insert(a[j]) ; int sum = 0; int rest = d-(i-start+1) ; if(rest<0) break ; while(el.size()>rest) el.erase(el.begin()); for(int x: el) sum+=x ; ans=max(ans,sum) ; // cout << i << " "<< sum << endl ; for(int j=start-1;j>-1;--j){ rest = d-(min(start-j,i-start)*2+max(start-j,i-start)); //cout << i << " "<< j << " "<< rest << endl ; if(rest<0) break ; el.insert(a[j]) ; sum+=a[j] ; while(el.size()>rest){ sum-=*el.begin(); el.erase(el.begin()) ; } //cout << i << " "<< j << " "<< rest << " " << sum << endl ; ans=max(ans,sum) ; } } return ans ; #undef int } /*int main(){ int a[5]= {10,2,20,30,1} ; cout << findMaxAttraction(5,2,7,a) ; return 0 ; } */

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:13:24: 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]
   13 |         while(el.size()>rest)
      |               ~~~~~~~~~^~~~~
holiday.cpp:24: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]
   24 |             while(el.size()>rest){
      |                   ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...