QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39933#4355. SeesawZeinDanerCompile Error//C++1.2kb2022-07-14 23:27:012022-07-14 23:27:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-14 23:27:03]
  • 评测
  • [2022-07-14 23:27:01]
  • 提交

answer

=#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<ii,dd> iidd;
const int MAX_N=2e5+10;
const int MAX=1e9+1;
vector<int> x;
int n;
double pre[2010][2010];
double cost(double lm){
  int l=0,r=n-1;
  double ma=pre[0][n-1];
  if(lm>ma) return MAX;
  for(int i=0;i<n-1;i++){
    if(pre[l+1][r]>=lm && pre[l][r-1]>=lm){
      if(pre[l+1][r]>pre[l][r-1])
	r--;
      else l++;
    }
    else{
      if(pre[l+1][r]>=lm)
	l++;
      else{
	if(pre[l][r-1]>=lm) r--;
	else return MAX;
      }
    }
    ma=max(ma,pre[l][r]);
  }
  return ma-lm;
}
int main(){
   scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a; scanf("%d",&a);
    x.push_back(a);
  }
  for(int i=0;i<n;i++){
    ll sum=0;
    double c=0;
    for(int j=i;j<n;j++){
      c++;
      sum+=x[j];
      pre[i][j]=(sum/c);
    }
  }
  double l=0,r=MAX;
  for(int i=0;i<=100;i++){
    double m1=l+(r-l)/3;
    double m2=r-(r-l)/3;
    double c1=cost(m1);
    double c2=cost(m2);
    if(c1>c2) l=m1;
    if(c2>c1) r=m2;
    if(c1==c2){
      l=m1; r=m2;
    }
  }
  printf("%.12f\n",cost(l));
}

详细

answer.code:1:2: error: stray ‘#’ in program
    1 | =#include <bits/stdc++.h>
      |  ^
answer.code:1:1: error: expected unqualified-id before ‘=’ token
    1 | =#include <bits/stdc++.h>
      | ^
answer.code:4:9: error: ‘pair’ does not name a type
    4 | typedef pair<int,int> ii;
      |         ^~~~
answer.code:5:9: error: ‘pair’ does not name a type
    5 | typedef pair<double,double> dd;
      |         ^~~~
answer.code:6:9: error: ‘pair’ does not name a type
    6 | typedef pair<ii,dd> iidd;
      |         ^~~~
answer.code:9:1: error: ‘vector’ does not name a type
    9 | vector<int> x;
      | ^~~~~~
answer.code: In function ‘double cost(double)’:
answer.code:30:8: error: ‘max’ was not declared in this scope; did you mean ‘ma’?
   30 |     ma=max(ma,pre[l][r]);
      |        ^~~
      |        ma
answer.code: In function ‘int main()’:
answer.code:35:4: error: ‘scanf’ was not declared in this scope
   35 |    scanf("%d",&n);
      |    ^~~~~
answer.code:38:5: error: ‘x’ was not declared in this scope
   38 |     x.push_back(a);
      |     ^
answer.code:45:12: error: ‘x’ was not declared in this scope
   45 |       sum+=x[j];
      |            ^
answer.code:61:3: error: ‘printf’ was not declared in this scope
   61 |   printf("%.12f\n",cost(l));
      |   ^~~~~~
answer.code:1:1: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
  +++ |+#include <cstdio>
    1 | =#include <bits/stdc++.h>