#55269: cpp_answer


yp11451202@yphs.tp.edu.tw (705-38黃鈺潤)


 

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

using namespace std;

int main() {
    // 優化輸入輸出速度
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int score;
    int min_x = 1000001; // 設一個比可能的最大值還大的初始值
    int max_x = -1;      // 設一個比可能的最小值還小的初始值

    // 持續讀取整數直到輸入結束
    while (cin >> score) {
        if (score < min_x) min_x = score;
        if (score > max_x) max_x = score;
        
        // 檢查下一個字元是否為換行或 EOF,這在某些線上評測系統中很有用
        if (cin.peek() == '\n' || cin.peek() == EOF) break;
    }

    // 根據推導:
    // a 為原始成績的最小值
    // b 為原始成績的最大值與最小值的差
    int a = min_x;
    int b = max_x - min_x;

    cout << a << " " << b << endl;

    return 0;
}