제출 #294377

#제출 시각아이디문제언어결과실행 시간메모리
294377peti1234팀들 (IOI15_teams)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long n, pos, sum; vector<pair<int, int> > sz; vector<int> kerd; bool can(int m, int[] a) { pos=0, sum=0; for (int i=0; i<m; i++) sum+=a[i]; if (sum>n) return 0; for (int i=0; i<m; i++) for (int j=0; j<a[i]; j++) kerd.push_back(a[i]); sort(kerd.begin(), kerd.end()); for (int i=0; i<n; i++) { if (pos<sum && sz[i].second<=kerd[pos] && kerd[pos]<=sz[i].first) pos++; } return (pos==sum); } void init(int p, int a[], int b[]) { n=p; for (int i=0; i<n; i++) sz.push_back(b[i], a[i]); sort(sz.begin(), sz.end()); }

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

teams.cpp:7:23: error: expected ',' or '...' before 'a'
    7 | bool can(int m, int[] a) {
      |                       ^
teams.cpp: In function 'bool can(int, int*)':
teams.cpp:9:34: error: 'a' was not declared in this scope
    9 |     for (int i=0; i<m; i++) sum+=a[i];
      |                                  ^
teams.cpp:11:45: error: 'a' was not declared in this scope
   11 |     for (int i=0; i<m; i++) for (int j=0; j<a[i]; j++) kerd.push_back(a[i]);
      |                                             ^
teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:20:52: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   20 |     for (int i=0; i<n; i++) sz.push_back(b[i], a[i]);
      |                                                    ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from teams.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note:   candidate expects 1 argument, 2 provided