제출 #1258283

#제출 시각아이디문제언어결과실행 시간메모리
1258283medmdg축제 (IOI25_festival)C++20
컴파일 에러
0 ms0 KiB
#include "festival.h"
#include<bits/stdc++.h>
#define mk(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
ll n;
vector<pair<ll,int>> t[4];
set<pair<ll,ll>> s;
ll a;
vector<ll> p;
int getP1(ll a){
  if(a<0)return 0;
  set<pair<ll,ll>>::iterator t=s.lower_bound(mk(a+1,-1));
  if(t==s.begin())return 0;
  t--;
  ll ans= (*t).second;
  return ans;
}
vector<int> sub3(){
  ll ma=getP1(a);
  ll nb=0;
  
  for(int i=0;i<t[1].size();i++){
    a-=t[1][i].first;
    if(a<1e17)
      a*=2;
    if(a<0)break;
    ll nma=getP1(a)+i+1;
    if(nma>ma){
      ma=nma;
      nb=i+1;
    }
  }
  vector<int> ans;
  for(int i=0;i<nb;i++){
    ans.push_back(t[1][i].second);
  }
  for(int i=nb;i<ma;i++){
    ans.push_back(t[0][i-nb].second);
  }
  return ans;
}
vector<int> max_coupons(int A, vector<int> P, vector<int> T) {
  for(int i=0;i<4;i++)t[i].clear();
  for(int i=0;i<T.size();i++){
    t[T[i]-1].push_back(mk(P[i],i));
  }
  for(int i=0;i<4;i++)  sort(t[i].begin(),t[i].end());
  s.clear();
  s.insert(mk(0,0));
  ll ps=0;
  for(int i=0;i<t[0].size();i++){ ps+=t[0][i].first;s.insert(mk(ps,i+1));}
  n=P.size();
  a=A;
  p=P;
  return sub3();
}

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

festival.cpp: In function 'std::vector<int> max_coupons(int, std::vector<int>, std::vector<int>)':
festival.cpp:55:5: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   55 |   p=P;
      |     ^
In file included from /usr/include/c++/11/vector:72,
                 from festival.h:1,
                 from festival.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from festival.h:1,
                 from festival.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~