QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675074#8242. V-Diagram1ockhartCompile Error//C++201.2kb2024-10-25 17:55:542024-10-25 17:55:56

Judging History

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

  • [2024-10-25 17:55:56]
  • 评测
  • [2024-10-25 17:55:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")

using ll = long long;
//using i128 = __int128_t;
#define endl "\n"
#define int long long
#define db cout << "db" << endl;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 5e5 + 10;
ll inf = 2e18;
#define double long double
void solve() {
    int n;
    cin >> n;
    vector<long double> a(n + 1);
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    }
    int p;
    for (int i = 2; i < n; i++) {
    	if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
    		p = i;
    	}
    }
    double sum1 = 0;
    for (int i = 1; i <= p + 1; i++) {
    	sum1 += a[i];
    }
    double ans = sum1 / (p + 1);
    for (int i = p + 2; i <= n; i++) {
    	sum1 += a[i];
    	ans = max(ans, sum1 / i);
    }
    for (int i = 1; i < p; i++) {
    	sum1 -= a[i];
    	ans = max(ans, sum1 / (n - i));
    }
    cout << fixed << setprecision(20) << ans << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int q = 1;
    cin >> q;
    while (q --) {
        solve();
    }
    return 0;
} 

詳細信息

answer.code: In function ‘void solve()’:
answer.code:17:16: error: ‘long long’ specified with ‘double’
   17 | #define double long double
      |                ^~~~
answer.code:21:17: note: in expansion of macro ‘double’
   21 |     vector<long double> a(n + 1);
      |                 ^~~~~~