답안 #625676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625676 2022-08-10T16:51:34 Z GordonRemzi007 Addk (eJOI21_addk) C++17
0 / 100
2000 ms 596 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 - l + 1 >= m ? r - l - m + 2 : 0); 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()) {
      |         ~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 49 ms 340 KB Output is correct
3 Incorrect 345 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2073 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -