반응형
    
    
    
  -문제

-코드
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int sum=0, p1=0, p2=8;
	vector<int> a(9);
	for (int i = 0; i<9; i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a.begin(), a.end());
	
	while (p1<p2)
	{
		if (sum - (a[p1] + a[p2]) == 100) break;
		else if (sum - (a[p1] + a[p2]) > 100) p1++;
		else p2--;
	}
	for (int i = 0; i < 9; i++)
	{	
		if (i == p1 || i == p2) continue;
		printf("%d\n", a[i]);
	}
	return 0;
}반응형
    
    
    
  '이론 > 코딩테스트' 카테고리의 다른 글
| [백준] 2583번 영역 구하기 (BFS) (0) | 2022.08.08 | 
|---|---|
| [백준] 16953번 A -> B (그리디 알고리즘) (0) | 2022.08.07 | 
| [백준] 1439번 뒤집기 (그리디 알고리즘) (0) | 2022.08.05 | 
| [백준] 1789번 수들의 합 (그리디 알고리즘) (0) | 2022.08.05 | 
| [백준] 110447번 동전0 (그리디 알고리즘) (0) | 2022.08.05 | 
 
                    
                   
                    
                   
                    
                  