Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 정석
- 정석학술정보관
- OS
- Operating System
- coding
- Computer science
- 컴공과
- Stack
- 오에스
- bfs
- DP
- 오퍼레이팅시스템
- vector
- 백준
- 브루트포스
- 문제풀이
- 구현
- 컴공
- 자료구조
- 알고리즘
- c++
- cs
- 그래프
- 코딩
- 너비우선탐색
- 개발
- 코테
- 북리뷰
- 컴퓨터공학과
- 스택
Archives
- Today
- Total
Little Jay
[C++] 백준 11399번 - ATM 본문
sort를 잘 사용하면 되는 문제
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> v;
v.resize(n);
int total = 0;
for (int i = 0; i < n; i++) {
cin >> v[i];
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++) {
for (int j = 0; j <= i; j++) {
total += v[j];
}
}
cout << total << "\n";
return 0;
}'알고리즘 > BOJ' 카테고리의 다른 글
| [C++] 백준 1620 - 나는야 포켓몬 마스터 이다솜 (0) | 2021.08.17 |
|---|---|
| [C++] 백준 11659 - 구간 합 구하기 4 (0) | 2021.08.16 |
| [C++] 백준 1463번 - 1로 만들기 (0) | 2021.08.16 |
| [C++] 백준 17219번 - 비밀번호 찾기 (0) | 2021.08.16 |
| [C++] 백준 11723번 - 집합 (0) | 2021.08.14 |
Comments