728x90
ez
swea๋ ๋์ด๋๊ฐ ๋ค์ฅ๋ ์ฅ์ด๋ผ๋๋ ๋ง๋ ๋ง์ธ ๊ฒ ๊ฐ๋ค
์ด ๋ฌธ์ ๋ D2๋ณด๋ค ์ฌ์ด๋ฏ
๋์ ํ์ด
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, char** argv)
{
ios_base::sync_with_stdio(false);
cin.tie(0);
// freopen("input (3).txt", "r", stdin);
int test_case;
int T = 10;
int dump = 0;
int num = 0;
int answer = 0;
// cin >> T;
for(test_case = 1; test_case <= T; ++test_case)
{
vector<int> v;
cin >> dump;
for (int i = 0; i < 100; ++i){
cin >> num;
v.push_back(num);
}
for (int i = 0; i < dump; ++i){
int maxi = max_element(v.begin(), v.end()) - v.begin();
int mini = min_element(v.begin(), v.end()) - v.begin();
v[maxi] -= 1;
v[mini] += 1;
}
answer = *max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end());
cout << "#" << test_case << " " << answer << "\n";
}
return 0;
}
728x90
'๐ ์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++/SWEA] 1859. ๋ฐฑ๋ง ์ฅ์ ํ๋ก์ ํธ (D2) (0) | 2024.11.16 |
---|---|
[C++/SWEA] 21425. += (D2) (0) | 2024.11.16 |
[C++/SWEA] 1215. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 3์ผ์ฐจ - ํ๋ฌธ1 (D3) (0) | 2024.11.16 |
[C++/SWEA] 1206. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - View (D3) (0) | 2024.11.16 |