제출 #102929

#제출 시각아이디문제언어결과실행 시간메모리
102929CaroLinda휴가 (IOI14_holiday)C++14
0 / 100
21 ms1312 KiB
#include <bits/stdc++.h>
// #include "holiday.h"

#define lp(i,a,b,v) for(int i=a;i<b;i = i + v)
#define MAXN 100005
#define pb push_back
#define pii pair<int,int>
#define ss second
#define ff first
#define lli long long int

using namespace std;

multiset<int> m ;

int d1[MAXN] , d2[MAXN] ;

int resp ;

void tira()
{
  resp -= *m.begin() ;
  m.erase( m.begin() ) ;
  
}

void calc (int val, int cons , int n, int S, int d , int a[])
{
  resp = 0 ;
  m.clear() ;
  for(int i = S ; i < min(S + cons , n ) and i>=max(0, S - cons) ; i += val)
  {
    resp += a[i] ;
    m.insert(a[i]) ;
    if(m.size() >  cons - abs(i - S)) 
    {
      if(cons-abs(i-S) + 1 != m.size() )
      {
        resp -= *m.begin() ;
        m.erase(m.begin()) ;
      }

      tira() ;

    } 
    if( val == 1 ) d1[cons] = max( resp  , d1[cons] );
    else d2[cons] = max(resp,d2[cons]) ;
  }

  // printf("%lld\n", d1[cons]) ;
  // printf("%lld\n", d2[cons]) ;

}

int findMaxAttraction(int n, int start, int d,int a[])
{ 
  calc(1,d,n,start,d,a) ;
  return d1[d] ;
}

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

holiday.cpp: In function 'void calc(int, int, int, int, int, int*)':
holiday.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(m.size() >  cons - abs(i - S)) 
        ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
holiday.cpp:37:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(cons-abs(i-S) + 1 != m.size() )
          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...