1552021-02-03 20:04:49kovacs.peter.18fZenehallgatáscpp11Forditási hiba
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct time {
	int second;
	int index;
	int song;
};

int main() {
	cin.sync_with_stdio(false);
	cin.tie(nullptr);

	int N, K;
	cin >> N >> K;
	vector<int> songS(N);
	int full_time = 0;
	for (auto& e : songS) {
		cin >> e;
		full_time += e;
	}
	vector<time> timeS(K);
	for (int i = 0; i < K; i++) {
		cin >> timeS[i].second;
		timeS[i].index = i;
	}
	sort(timeS.begin(), timeS.end(), [](time a, time b) {
		return a.second < b.second;
	});
	int song = 0;
	long long length = songS[0];
	for (auto& e : timeS) {
		while (e.second > length) {
			song = (song == N - 1 ? 0 : song + 1);
			length += songS[song];
		}
		e.song = song + 1;
	}
	sort(timeS.begin(), timeS.end(), [](time a, time b) {
		return a.index < b.index;
	});
	for (auto e : timeS) {
		cout << e.song << " ";
	}
}
Forditási hiba
exit status 1main.cpp: In function ‘int main()’:
main.cpp:25:13: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
   25 |  vector<time> timeS(K);
      |             ^
main.cpp:25:13: note:   expected a type, got ‘time’
main.cpp:25:13: error: template argument 2 is invalid
main.cpp:27:17: error: invalid types ‘int[int]’ for array subscript
   27 |   cin >> timeS[i].second;
      |                 ^
main.cpp:28:10: error: invalid types ‘int[int]’ for array subscript
   28 |   timeS[i].index = i;
      |          ^
main.cpp:30:13: error: request for member ‘begin’ in ‘timeS’, which is of non-class type ‘int’
   30 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |             ^~~~~
main.cpp:30:28: error: request for member ‘end’ in ‘timeS’, which is of non-class type ‘int’
   30 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                            ^~~
main.cpp:30:38: error: ‘time’ is not a type
   30 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                      ^~~~
main.cpp:30:46: error: ‘time’ is not a type
   30 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                              ^~~~
main.cpp: In lambda function:
main.cpp:31:12: error: request for member ‘second’ in ‘a’, which is of non-class type ‘int’
   31 |   return a.second < b.second;
      |            ^~~~~~
main.cpp:31:23: error: request for member ‘second’ in ‘b’, which is of non-class type ‘int’
   31 |   return a.second < b.second;
      |                       ^~~~~~
main.cpp: In function ‘int main()’:
main.cpp:35:17: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
   35 |  for (auto& e : timeS) {
      |                 ^~~~~
      |                 std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from main.cpp:1:
/usr/include/c++/9/bits/range_access.h:87:5: note: ‘std::begin’ declared here
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
main.cpp:35:17: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
   35 |  for (auto& e : timeS) {
      |                 ^~~~~
      |                 std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from main.cpp:1:
/usr/include/c++/9/bits/range_access.h:97:5: note: ‘std::end’ declared here
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
main.cpp:42:13: error: request for member ‘begin’ in ‘timeS’, which is of non-class type ‘int’
   42 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |             ^~~~~
main.cpp:42:28: error: request for member ‘end’ in ‘timeS’, which is of non-class type ‘int’
   42 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                            ^~~
main.cpp:42:38: error: ‘time’ is not a type
   42 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                      ^~~~
main.cpp:42:46: error: ‘time’ is not a type
   42 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                              ^~~~
main.cpp: In lambda function:
main.cpp:43:12: error: request for member ‘index’ in ‘a’, which is of non-class type ‘int’
   43 |   return a.index < b.index;
      |            ^~~~~
main.cpp:43:22: error: request for member ‘index’ in ‘b’, which is of non-class type ‘int’
   43 |   return a.index < b.index;
      |                      ^~~~~
main.cpp: In function ‘int main()’:
main.cpp:45:16: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
   45 |  for (auto e : timeS) {
      |                ^~~~~
      |                std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from main.cpp:1:
/usr/include/c++/9/bits/range_access.h:87:5: note: ‘std::begin’ declared here
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
main.cpp:45:16: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
   45 |  for (auto e : timeS) {
      |                ^~~~~
      |                std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from main.cpp:1:
/usr/include/c++/9/bits/range_access.h:97:5: note: ‘std::end’ declared here
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
Exited with error status 1