166 2021. 02. 03 21:09:10 Szin Attila Zenehallgatás cpp11 Forditá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<typename 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:25:22: error: template argument 1 is invalid
   25 |  vector<typename time> timeS(K);
      |                      ^
main.cpp:25:22: 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: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: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: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