1642021-02-03 21:06:40Szin AttilaZenehallgatá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<time> 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 (int i = 0; i < songS.size(); i++) {
		time e = sogS[i];
		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 (int i = 0; i < songS.size(); i++) {
		time e = sogS[i];
		cout << e.song << " ";
	}
}
Forditási hiba
exit status 1main.cpp: In function ‘int main()’:
main.cpp:19:13: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
   19 |  vector<time> songS(N);
      |             ^
main.cpp:19:13: note:   expected a type, got ‘time’
main.cpp:19:13: error: template argument 2 is invalid
main.cpp:21:17: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
   21 |  for (auto& e : songS) {
      |                 ^~~~~
      |                 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:21:17: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
   21 |  for (auto& e : songS) {
      |                 ^~~~~
      |                 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: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:34:28: error: invalid types ‘int[int]’ for array subscript
   34 |  long long length = songS[0];
      |                            ^
main.cpp:35:28: error: request for member ‘size’ in ‘songS’, which is of non-class type ‘int’
   35 |  for (int i = 0; i < songS.size(); i++) {
      |                            ^~~~
main.cpp:36:7: error: expected ‘;’ before ‘e’
   36 |   time e = sogS[i];
      |       ^~
      |       ;
main.cpp:37:10: error: ‘e’ was not declared in this scope
   37 |   while (e.second > length) {
      |          ^
main.cpp:39:24: error: invalid types ‘int[int]’ for array subscript
   39 |    length += songS[song];
      |                        ^
main.cpp:41:3: error: ‘e’ was not declared in this scope
   41 |   e.song = song + 1;
      |   ^
main.cpp:43:13: error: request for member ‘begin’ in ‘timeS’, which is of non-class type ‘int’
   43 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |             ^~~~~
main.cpp:43:28: error: request for member ‘end’ in ‘timeS’, which is of non-class type ‘int’
   43 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                            ^~~
main.cpp:43:38: error: ‘time’ is not a type
   43 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                      ^~~~
main.cpp:43:46: error: ‘time’ is not a type
   43 |  sort(timeS.begin(), timeS.end(), [](time a, time b) {
      |                                              ^~~~
main.cpp: In lambda function:
main.cpp:44:12: error: request for member ‘index’ in ‘a’, which is of non-class type ‘int’
   44 |   return a.index < b.index;
      |            ^~~~~
main.cpp:44:22: error: request for member ‘index’ in ‘b’, which is of non-class type ‘int’
   44 |   return a.index < b.index;
      |                      ^~~~~
main.cpp: In function ‘int main()’:
main.cpp:46:28: error: request for member ‘size’ in ‘songS’, which is of non-class type ‘int’
   46 |  for (int i = 0; i < songS.size(); i++) {
      |                            ^~~~
main.cpp:47:7: error: expected ‘;’ before ‘e’
   47 |   time e = sogS[i];
      |       ^~
      |       ;
main.cpp:48:11: error: ‘e’ was not declared in this scope
   48 |   cout << e.song << " ";
      |           ^
Exited with error status 1