Submission #625667

# Submission time Handle Problem Language Result Execution time Memory
625667 2022-08-10T16:36:58 Z GordonRemzi007 Addk (eJOI21_addk) C++17
0 / 100
2000 ms 1104 KB
//addk
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
	int n, k, q;
	int l, r, m;
	int res;
	vector<int> a, temp;
	string result;
	cin >> n;
	cin >> k;
	for (int i = 0; i < n; i++) {
		cin >> q;
		a.push_back(q);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		res = 0;
		temp.clear();
		cin >> n;
		if (n == 1) {
			for (int i = 0; i < k; i++) {
				cin >> n;
				temp.push_back(n);
			}
			for (int i = 0; i < temp.size(); i++) {
				if (i + 1 == temp.size()) {
					a[temp[i] - 1] = a[temp[0] - 1];
					break;
				}
				a[temp[i] - 1] = a[temp[i + 1] - 1];
			}
		}
		else {
			cin >> l;
			cin >> r;
			cin >> m;
			for (int i = 0; i < r - m; i++) {
				for (int j = 0; j < m; j++) res += a[l + i + j - 1];
			}
			result.append(to_string(res).append("\n"));
		}
	}
	cout << result;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for (int i = 0; i < temp.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
Main.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if (i + 1 == temp.size()) {
      |         ~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2066 ms 1104 KB Time limit exceeded
2 Halted 0 ms 0 KB -