제출 #1047200

#제출 시각아이디문제언어결과실행 시간메모리
1047200EntityPlanttBouquet (EGOI24_bouquet)C++17
24 / 100
18 ms1248 KiB
#include <iostream>
using namespace std;

const int N = 2e5 + 5;
int dp[N];

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	bool subt1 = true;
	int n, rd;
	cin >> n;
	dp[0] = 1;
	for (int i = 0, l, r; i < n; i++) {
		cin >> l >> r;
		if (l == r) {
			if (!i) rd = l;
			else if (rd != l) subt1 = false;
		}
		else subt1 = false;
		if (i) dp[i] = dp[i - 1];
		if (i > l) dp[i] = max(dp[i], dp[i - l - 1] + 1);
	}
	if (subt1) cout << (n + rd) / (rd + 1);
	else cout << dp[n - 1];
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:24:36: warning: 'rd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  if (subt1) cout << (n + rd) / (rd + 1);
      |                                ~~~~^~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…