N, M = list(map(int, input().split()))
numbers = list(map(int, input().split()))
max = 0
for i in range(0, len(numbers)):
    for j in range(i+1, len(numbers)):
        for k in range(j+1, len(numbers)):
            temp = numbers[i] + numbers[j] + numbers[k]
            if temp > max and temp <=M:
                max = temp
print (max)
#include <iostream>
using namespace std;

bool checkLeapYear(int year)
{
	if ((year % 4 == 0 and year % 100 != 0) or (year % 4 ==0 and year % 400 == 0))
	{
		return true;
	}
	
	else
	{
		return false;
	}
}

int main(void)
{
	int result = -1; // 여부 확인 
	int year = 0; // 입력 연도 

	cin >> year;
	
	if (year>=1 and year<=4000)
	{
		result = checkLeapYear(year);
		cout << result << endl; 	
	}

	return 0;
}
import sys
input = sys.stdin.readline

fibo_nums = [0, 1]
for i in range(90):
    fibo_nums.append(sum([fibo_nums[-1], fibo_nums[-2]]))
    
n = int(input())
print (fibo_nums[n])

 

import sys
input = sys.stdin.readline

fibo_nums = [0, 1]
for i in range(90):
    fibo_nums.append(sum([fibo_nums[-1], fibo_nums[-2]]))
    
n = int(input())
print (fibo_nums[n])

 

import sys
input = sys.stdin.readline

fibo_nums = [0, 1]
for i in range(45):
    fibo_nums.append(sum([fibo_nums[-1], fibo_nums[-2]]))
    
n = int(input())
print (fibo_nums[n])
#include <iostream>

using namespace std;

int main(void)
{
	int N = 0;
	
	cin >> N;
	
	if (N>=1 and N<=100000)	
	{
		for (int i=N; i>0; i--)
		{
			cout << i << '\n';
		}
	}
	
	return 0;
}
#include <iostream>

using namespace std;

int main(void)
{
	int N = 0;
	
	cin >> N;
	
	if (N>=1 and N<=100000)
	{
		for (int i=1; i<=N; i++)
		{
			cout << i << '\n';
		}
	}
}
#include <stdio.h>

int main(void)
{
	int N = 0;
	
	scanf("%d", &N);
	
	if (N >= 1 and N <= 9)
	{
		for (int i=1; i<=9; i++)
		{
			printf("%d * %d = %d\n", N, i, N*i);
		}
	}
	
	else
		return 0;
		
	return 0;
}
import sys
T = int(input())
for _ in range(T):
    count, string = sys.stdin.readline().split()
    P = ""
    for s in range(len(string)):
        P += string[s] * int(count)
        if s == len(string) -1:
            print (P)

'Computer Science > 백준 알고리즘' 카테고리의 다른 글

[백준] 2741번 N 찍기 (C++)  (0) 2022.03.16
[백준] 2739번 구구단 (C)  (0) 2022.03.16
[백준] 2588번 곱셈 (C++)  (0) 2022.03.16
[백준] 2581번 소수 (C++)  (0) 2022.03.16
[백준] 2577번 숫자의 개수 (C++)  (0) 2022.03.16

 

#include <iostream>
// 몫과 나머지 계산 + 자연수 길이 구하기 
using namespace std;

int getIntLen(int value)
{
	int count = 0;

	do
	{
		value = int(value/10);
		count++;
	}while(value > 0);
	
	return count;
}


int main(void)
{
	// 세자리 자연수 
	int N1, N2 = 0;
	
	// 자연수 길이
	int L1, L2 = 0; 
	
	// 중간 계산 
	int N3, N4, N5 = 0;
		
	cin >> N1;
	cin >> N2;
	
	L1 = getIntLen(N1);
	L2 = getIntLen(N2);
	
	if (L1 == 3 and L2 == 3)
	{
		N3 = N1 * (N2 % 10);
		N4 = N1 * ((N2 / 10) % 10);
		N5 = N1 * ((N2 / 100));
		
		cout << N3 << endl;
		cout << N4 << endl;
		cout << N5 << endl;
		
		cout << N1 * N2 << endl;
	}
	
	return 0;
}

+ Recent posts