제출 #1258276

#제출 시각아이디문제언어결과실행 시간메모리
1258276medmdgFestival (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<int,int>> t[4];
set<pair<ll,ll>> s;
int a;
vector<int> p;
int getP1(ll a){
  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-=p[t[1][i].second];
    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> sub3()':
festival.cpp:34:17: error: 'nb' was not declared in this scope; did you mean 'n'?
   34 |   for(int i=0;i<nb;i++){
      |                 ^~
      |                 n
festival.cpp:37:13: error: 'nb' was not declared in this scope; did you mean 'n'?
   37 |   for(int i=nb;i<ma;i++){
      |             ^~
      |             n