답안 #436579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436579 2021-06-24T16:13:25 Z shrimb 사탕 분배 (IOI21_candies) C++17
3 / 100
125 ms 8036 KB
#include"bits/stdc++.h"
// #define int long long
#define endl '\n'
using namespace std;

vector<int> distribute_candies (vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
	int n = c.size();
	int q = l.size();

	bool st1 = (n <= 2000 and q <= 2000);
	bool st2 = 1; for (int i = 0 ; i < q ; i++) if (v[i] < 0) st2 = 0;

	if (st1) {
		vector<int> ret(n, 0);
		for (int i = 0 ; i < q ; i++) {
			for (int j = l[i] ; j <= r[i] ; j++) {
				ret[j] = max(0, min(c[j], ret[j] + v[i]));
			}
		}
		return ret;
	}
	if (st2) {
		vector<int> ret(n, 0);
		vector<int> pref(n + 1, 0);
		for (int i = 0 ; i < q ; i++) {
			pref[l[i]] += v[i];
			pref[r[i] + 1] -= v[i];
		}
		for (int i = 1 ; i < n ; i++) pref[i] += pref[i-1];
		for (int i = 0 ; i < n ; i++) ret[i] = min(c[i], pref[i]);
		return ret; 
	}

}

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:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 125 ms 8036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 63 ms 4952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 78 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Incorrect 125 ms 8036 KB Output isn't correct
7 Halted 0 ms 0 KB -