CCF CSP 竞赛试题——小中大(201903-1)

  • 浮点计算是不精确的
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

void print(int x) {
    cout << x / 2 << (x & 1 ? ".5 " : " ");
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) cin >> A[i];
    vector<int> res(3);
    res[0] = A[0] << 1, res[1] = A[n - 1] << 1, res[2] = A[(n - 1) / 2] + A[n / 2];
    sort(res.begin(), res.end());
    for (int i = 2; i >= 0; --i) print(res[i]);
    return 0;
}
发布了33 篇原创文章 · 获赞 4 · 访问量 8741

猜你喜欢

转载自blog.csdn.net/Touchig/article/details/102832538
今日推荐