Submission #100978

# Submission time Handle Problem Language Result Execution time Memory
100978 2019-03-15T16:28:44 Z KLPP Akvizna (COCI19_akvizna) C++14
20 / 130
1500 ms 24848 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;
double DP[3001][3001];
int oper;
void compute(int level,int lo_i,int hi_i, int lo_j, int hi_j){
  if(lo_i>hi_i)return;
  oper+=hi_j-max(lo_j,level-1)+1;
  //cout<<level<<" "<<lo_i<<" "<<hi_i<<" "<<lo_j<<" "<<hi_j<<endl;
  int mid=(lo_i+hi_i);
  DP[mid][level]=0;
  int opt=-1;
  for(int i=max(lo_j,level-1);i<=hi_j && i<mid;i++){
    if(DP[mid][level]<DP[i][level-1]+(double)(mid-i)/(mid)){
      DP[mid][level]=DP[i][level-1]+(double)(mid-i)/(mid);
      opt=i;
    }
    //DP[mid][level]=max(DP[mid][level],DP[i][level-1]+(double)(mid-i)/(mid));
  }
  compute(level,lo_i,mid-1,lo_j,opt);
  compute(level,mid+1,hi_i,opt,hi_j);
}
int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  for(int i=0;i<=n;i++)DP[i][0]=0;
  for(int i=1;i<=n;i++){
    /* for(int j=1;j<=k && j<=i;j++){
      DP[i][j]=0;
      //cout<<i<<" A  "<<j<<endl;
      for(int l=j-1;l<i;l++){
	double d=(double)(i-l)/i;
	//cout<<l<<" "<<d<<endl;
	DP[i][j]=max(DP[i][j],DP[l][j-1]+d);
      }
      
      //printf("%lf ",DP[i][j]);
      //cout<<endl;
    }//printf("\n");*/
  }
  for(int i=1;i<=k;i++){oper=0;
    compute(i,0,n,0,n);
    //cout<<i<<" "<<oper<<endl;
  }
  
  printf("%.10lf\n",DP[n][k]);
  return 0;
}

Compilation message

akvizna.cpp: In function 'int main()':
akvizna.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&k);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1510 ms 13764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1564 ms 14748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1558 ms 14724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1553 ms 14492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1555 ms 14260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1565 ms 14008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1551 ms 14892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1515 ms 14084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1531 ms 14908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 24696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 69 ms 24656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 67 ms 24848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 64 ms 24712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 24704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 63 ms 24772 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 24796 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 24696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 24824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 70 ms 24672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 67 ms 24740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 24756 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 24784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -