일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 수성못삼겹살
- 조건문
- 들안길삼겹살
- 대구카페
- 반복문
- 대구고깃집
- 정렬
- 큐
- 수성못맛집
- programmers
- 수성구맛집
- 대구삼겹살
- 백준
- 대명동맛집
- C#
- SQL
- 서울맛집
- 앞산카페
- 대구맛집
- 압구정데이트
- 별찍기
- 수성구데이트
- 범어동맛집
- 브루트 포스
- BFS
- 오라클
- oracle
- 안지랑카페
- 프로그래머스
- 대구데이트
- Today
- Total
모든 일상
C# 백준 2798번 문제 블랙잭 본문
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] str = Console.ReadLine().Split();
int cnt = int.Parse(str[0]);
int num = int.Parse(str[1]);
int max = int.MinValue;
int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray(); // string으로 입력받고 int형태의 배열로 저장
for (int i = 0; i<cnt; i++ )
{
for(int j = i+1; j<cnt; j++)
{
for(int k = j+1; k<cnt; k++)
{
int sum = arr[i] + arr[j] + arr[k];
if (sum <= num && sum > max) max = sum;
}
}
}
Console.WriteLine(max);
}
}
}
'코딩 공부 > C#' 카테고리의 다른 글
C# 백준 2564번 색종이 문제 (0) | 2023.02.16 |
---|---|
C# 백준 2231번 문제 분해합 (0) | 2023.01.12 |
C# 백준 1427번 문제 소트인사이드 (0) | 2023.01.10 |
C# 백준 2108번 문제 통계학 (0) | 2023.01.10 |
C# 백준 2751번 문제 수 정렬하기2 (0) | 2023.01.10 |