Coding_Test - 8BitsCoding/RobotMentor GitHub Wiki

์ค€๋น„์‚ฌ์ดํŠธ


๊ธฐ๋ณธ์ฝ”๋“œ

input์ด ์•„๋ž˜์™€ ๊ฐ™์Œ

5 6 7 3 6 10

#include <bits/stdc++.h>

using namespace std;

int main() {
    vector<int> a_triplet(3);
    vector<int> b_triplet(3);

    for(int i = 0; i < 3; i++) {
        cin >> a_triplet[i];
    }

    for(int i = 0; i < 3; i++) {
        cin >> b_triplet[i];
    }
}

cin์€ ์ŠคํŽ˜์ด์Šค๋ฐ” ๋‹จ์œ„๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ์Œ.


Sort ์‚ฌ์šฉํ•˜๊ธฐ

5๊ฐœ์˜ ์ƒ์ˆ˜๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ๊ฐ€์žฅํฐ ํ•˜๋‚˜์˜ ๊ฐ’, ๊ฐ€์žฅ์ž‘์€ ํ•˜๋‚˜์˜ ๊ฐ’์„ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ๋ชจ๋‘ ๋”ํ•˜๊ธฐ

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
    long long a[5];
    long long sum = 0;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a, a+5);
    cout << sum - a[4] << " " << sum - a[0] << endl;
    return 0;
}
โš ๏ธ **GitHub.com Fallback** โš ๏ธ