Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 프로그래머스
- java정리
- Project
- 백준
- 풀스택프레임워크
- 주가예측
- 개인프로젝트
- Python
- frontend
- 자바
- 모의 주식
- 빅데이터
- C++
- Reflex
- 이웃한 칸
- 코스닥
- java
- 자바독학
- SNS
- 코딩테스트
- 코딩독학
- 프로그램
- 자바정리
- 프로그래밍
- 코딩
- 개발자
- 개발
- 사물인터넷
- backend
- 코테
Archives
- Today
- Total
Creative Code
[16496번]큰 수 만들기 본문
https://www.acmicpc.net/problem/16496
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
bool compare(string a, string b) {
return a + b > b + a;
}
string solution(vector<int>numbers) {
string max;
string answer;
vector<string>number;
for (int i = 0; i < numbers.size(); i++) {
number.push_back(to_string(numbers[i]));
}
sort(number.begin(), number.end(), compare);
for (int k = 0; k < number.size(); k++) {
answer += number[k];
}
if (answer[0] == '0') {
return "0";
}
return answer;
}
int main() {
int N;
cin >> N;
vector<int>aa;
for (int i = 1; i <= N; i++) {
int k;
cin >> k;
aa.push_back(k);
}
cout << solution(aa) << '\n';
}
'백준 문제풀이' 카테고리의 다른 글
[1107번]리모컨 (0) | 2023.09.24 |
---|---|
[17214번]다항 함수의 적분 (0) | 2023.09.06 |
[7869번]두 원 (0) | 2023.09.05 |
[2981번]검문 (0) | 2023.09.04 |
[2447번]별 찍기-10 (0) | 2023.09.03 |