Submission #102967

# Submission time Handle Problem Language Result Execution time Memory
102967 2019-03-28T09:08:11 Z mraron Akvizna (COCI19_akvizna) C++14
65 / 130
1500 ms 1152 KB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}


double dp[100001];
int cnt[100001];

int main() {
	IO;
	int n,k,it=0;
	cin>>n>>k;
	double L=0, R=2;
	while(1) {
		double mid=(L+R)/2;
		dp[0]=0.0;
		cnt[0]=0;
		for(int i=1;i<=n;++i) {
			dp[i]=0;
		}
		
		for(int i=0;i<=n;++i) {
			for(int j=1;i+j<=n;j++) {
				double akt=dp[i]+double(j)/double(n-i)-mid;
				if(dp[i+j]<akt) {
					dp[i+j]=akt;
					cnt[i+j]=cnt[i]+1;
				}
			}
		}
		if(cnt[n]<=k) {
			R=mid;
		}else {
			L=mid;
		}
		it++;
		if(it>=40 && cnt[n]==k) break ;
	}
	
	cout<<fixed<<setprecision(9);
	cout<<dp[n]+L*cnt[n]<<"\n";
	return 0;
}



/*
double dp[3001][3001];

int main() {
	IO;
	int n,k;
	cin>>n>>k;
	dp[n][0]=0.0;
	for(int i=1;i<=k;++i) {
		for(int j=0;j<=n;++j) {
			for(int l=0;l<=n/i && j+l<=n;l++) {
				dp[j][i]=max(dp[j][i], dp[j+l][i-1]+(l>0?(double)l/(double)(j+l):0));
			}
		}
	}
	cout<<fixed<<setprecision(10);	
	cout<<dp[0][k]<<"\n";
	return 0;
}*/



# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 307 ms 384 KB Output is correct
2 Correct 400 ms 504 KB Output is correct
3 Correct 404 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 370 ms 416 KB Output is correct
2 Correct 415 ms 420 KB Output is correct
3 Correct 513 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 516 ms 504 KB Output is correct
2 Correct 337 ms 384 KB Output is correct
3 Correct 294 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 416 KB Output is correct
2 Correct 366 ms 432 KB Output is correct
3 Correct 371 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 492 ms 356 KB Output is correct
2 Correct 433 ms 428 KB Output is correct
3 Correct 350 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 508 KB Output is correct
2 Correct 468 ms 420 KB Output is correct
3 Correct 409 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 398 ms 424 KB Output is correct
2 Correct 519 ms 424 KB Output is correct
3 Correct 397 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 372 ms 512 KB Output is correct
2 Correct 332 ms 420 KB Output is correct
3 Correct 365 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 384 ms 424 KB Output is correct
2 Correct 466 ms 428 KB Output is correct
3 Correct 487 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1550 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1553 ms 1024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1529 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1572 ms 1024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1572 ms 1024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1551 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1529 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1546 ms 1024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1550 ms 1124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1517 ms 1124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1571 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1548 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1570 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -