제출 #840099

#제출 시각아이디문제언어결과실행 시간메모리
840099Faisal_SaqibA Plus B (IOI23_aplusb)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> smallest_sum(int n,vector<int> a,vector<int> b) { vector<int> ans; int can[a.size()]; int m=b.size(); for(int i=0;i<n;i++) { can[i]=0; } set<pair<int,pair<int,int>>> pq; pq.insert({a[0]+b[0],{0,0}}); while(ans.size()<(k) and pq.size()>0) { auto p=*begin(pq); pq.erase(begin(pq)); ans.push_back(p.first); if(p.second.first< (n-1)){ pq.insert({a[p.second.first+1]+b[can[p.second.first+1]],{p.second.first+1,can[p.second.first+1]}}); } if(p.second.second< (m-1)) { pq.insert({a[p.second.first]+b[p.second.second+1],{p.second.first,p.second.second+1}}); can[p.second.first]+=1; } } return ans; }

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

aplusb.cpp: In function 'std::vector<int> smallest_sum(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:14:23: error: 'k' was not declared in this scope
   14 |     while(ans.size()<(k) and pq.size()>0)
      |                       ^