컴퓨터기본/문제풀이

[백준] 11399번: ATM

차가운오미자 2021. 6. 21. 21:18

아주 간단한 문제이다. 

그냥 돈 뽑는 시간 제일 짧은 것부터 정렬해서,

각 사람마다 인출 완료까지 걸리는 시간을 출력하면 된다. 

 

#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

using namespace std;

int main(void){
	
	vector<int> people;
	int n;
	cin >> n;
	cin.ignore();
	
	string str;
	getline(cin, str);
	stringstream ss(str);
	int temp;
	while(ss>>temp){
		people.push_back(temp);
	}
	
	sort(people.begin(), people.end());
	int result = 0;
	for(int i =0; i<people.size(); i++){
		for(int j = 0; j<i; j++){
			result += people[j];
		}
		result += people[i];
	}
	
	cout << result << endl;
}

'컴퓨터기본 > 문제풀이' 카테고리의 다른 글

[백준] 2164번: 카드2  (0) 2021.06.24
[백준] 18258번: 큐2  (0) 2021.06.24
[백준] 1931번: 회의실 배정  (0) 2021.06.21
[백준] 11047번: 동전 0  (0) 2021.06.21
[백준] 7576번: 토마토  (0) 2021.06.20