안녕하세요. 오늘은 코딩을 할거예요.

문제

https://www.acmicpc.net/problem/23348

아이디어

N번 반복하면 됩니다.
{
3번 a,b,c를 입력받고
다 곱해서 더한값의
최댓값을 구하면 됩니다.
}

소스코드

#include <iostream>
#include <algorithm>
using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int N, i, j, x, y, z, a, b, c, sum, ans = 0;
	cin >> x >> y >> z >> N;
	for (i = 0; i < N; i++)
	{
		sum = 0;
		for (j = 0; j < 3; j++)
		{
			cin >> a >> b >> c;
			sum += a * x + b * y + c * z;
		}
		ans = max(ans, sum);
	}
	cout << ans;
}


감사합니다.

0개의 댓글