답안 #592920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592920 2022-07-09T20:04:16 Z Luxry 사탕 분배 (IOI21_candies) C++17
3 / 100
5000 ms 13272 KB
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
	vector<int> s(c.size());
	for (int j = 0; j < v.size(); ++j) {
		if (v[j] > 0) {
			for (int k = l[j]; k <= r[j]; ++k) {
				s[k] = min(c[k], s[k] + v[j]);
			}
		}
		else if (v[j] < 0) {
			for (int k = l[j]; k <= r[j]; ++k) {
				s[k] = max(0, s[k] + v[j]);
			}
		}
	}
	return s;
}

int solve()
{
	int n;
	cin >> n;
	vector<int> c(n);

	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}

	int q;
	cin >> q;
	vector<int> l(q), r(q), v(q);

	for (int i = 0; i < q; ++i) {
		cin >> l[i], r[i], v[i];
	}

	vector<int> result = distribute_candies(c, l, r, v);
	for (int i = 0; i < n; ++i) {
		cout << result[i] << " ";
	}
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int j = 0; j < v.size(); ++j) {
      |                  ~~^~~~~~~~~~
candies.cpp: In function 'int solve()':
candies.cpp:45:1: warning: no return statement in function returning non-void [-Wreturn-type]
   45 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5025 ms 12196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 164 ms 8028 KB Output is correct
3 Correct 160 ms 5900 KB Output is correct
4 Execution timed out 5040 ms 13272 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 428 ms 7656 KB Output is correct
4 Correct 400 ms 3932 KB Output is correct
5 Execution timed out 5065 ms 10832 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 312 KB Output is correct
6 Execution timed out 5025 ms 12196 KB Time limit exceeded
7 Halted 0 ms 0 KB -