QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#466658#8524. Weather ForecastEl_7la2een#Compile Error//C++17929b2024-07-08 00:20:342024-07-08 00:20:34

Judging History

你现在查看的是最新测评结果

  • [2024-07-08 00:20:34]
  • 评测
  • [2024-07-08 00:20:34]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
int n, k;

bool check(vector<double>& v, double avg) {

    double sum = 0, num = 0;
    int cnt = 0;
    for (auto& i : v) {
        sum += i;
        num++;

        double av = sum / num;

        if (avg <= av) {
            cnt++;
            sum = 0;
            num = 0;
        }
    }

    return (cnt >= k);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


    cin >> n >> k;

    vector<double>v(n);
    for (auto& i : v)cin >> i;

    double l = 0, r = 10000;

    double ans = 0;
    for (int i = 0; i < 60; i++) {
        double md = (l + r) / 2.0;
        if (check(v, md)) {
            ans = md;
            l = md;
        }
        else r = md;
    }

    cout << fixed << setprecision(12) << ans << "\n";
}

详细

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<double, std::allocator<double> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = double]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~