제출 #1282032

#제출 시각아이디문제언어결과실행 시간메모리
1282032nataliaa축제 (IOI25_festival)C++20
컴파일 에러
0 ms0 KiB
#include "festival.h" #include<bits/stdc++.h> using namespace std; std::vector<int> max_coupons(int A, std::vector<int> P, std::vector<int> T) { pair<int,int> p; int n = P.size(); for(int i = 0; i <n; i++) { p[i].first = P[i]; p[i].second = i; } sort(p.begin(), p.end()); vector<int> v; int s = 0; for(int i = 0; i < n ; i++) { if(p[i].first<=A) { A-=p[i].first; v.push_back(p[i].second); s++; } else break; } return v; }

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

festival.cpp: In function 'std::vector<int> max_coupons(int, std::vector<int>, std::vector<int>)':
festival.cpp:8:10: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
    8 |         p[i].first = P[i];
      |          ^
festival.cpp:9:10: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
    9 |         p[i].second = i;
      |          ^
festival.cpp:11:12: error: 'struct std::pair<int, int>' has no member named 'begin'
   11 |     sort(p.begin(), p.end());
      |            ^~~~~
festival.cpp:11:23: error: 'struct std::pair<int, int>' has no member named 'end'
   11 |     sort(p.begin(), p.end());
      |                       ^~~
festival.cpp:15:13: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
   15 |         if(p[i].first<=A) {
      |             ^
festival.cpp:16:17: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
   16 |             A-=p[i].first;
      |                 ^
festival.cpp:17:26: error: no match for 'operator[]' (operand types are 'std::pair<int, int>' and 'int')
   17 |             v.push_back(p[i].second);
      |                          ^