QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702369 | #9540. Double 11 | ucup-team159# | WA | 0ms | 3876kb | C++23 | 3.7kb | 2024-11-02 15:51:31 | 2024-11-02 15:51:32 |
Judging History
answer
#line 1 "F.cpp"
// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")
#line 2 "/home/sigma/comp/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> bool chmax(T& x, U y){
if(x<y){ x=y; return true; }
return false;
}
template<class T,class U> bool chmin(T& x, U y){
if(y<x){ x=y; return true; }
return false;
}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class T>
V<T> Vec(size_t a) {
return V<T>(a);
}
template<class T, class... Ts>
auto Vec(size_t a, Ts... ts) {
return V<decltype(Vec<T>(ts...))>(a, Vec<T>(ts...));
}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
o<<"{";
for(const T& v:vc) o<<v<<",";
o<<"}";
return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
os<<t<<" ~ ";
dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {"; \
for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
template<class D> D divFloor(D a, D b){
return a / b - (((a ^ b) < 0 && a % b != 0) ? 1 : 0);
}
template<class D> D divCeil(D a, D b) {
return a / b + (((a ^ b) > 0 && a % b != 0) ? 1 : 0);
}
#line 5 "F.cpp"
int main(){
cin.tie(0);
ios::sync_with_stdio(false); //DON'T USE scanf/printf/puts !!
cout << fixed << setprecision(20);
int N,M; cin >> N >> M;
V<ll> A(N); rep(i,N) cin >> A[i];
sort(all(A));
V<ll> S(N+1); rep(i,N) S[i+1] = S[i] + A[i];
using P = pair<double,int>;
double inf = 1e100;
P infp(inf,-1);
auto f_brute = [&](double penalty) -> pair<double,int> {
V<P> dp(N+1, infp); dp[0] = P(0,0);
rep1(i,N){
rep(j,i){
double cost = sqrt((S[i]-S[j]) * (i-j)) + penalty;
chmin(dp[i],P(dp[j].fs+cost,dp[j].sc+1));
}
}
return dp[N];
};
auto f = [&](double penalty) -> pair<double,int> {
V<P> dp(N+1, infp); dp[0] = P(0,0);
int pj = 0; // [pj,i-1] をためす気持ち
auto getcost = [&](int j, int i) -> double {
return sqrt((S[i]-S[j]) * (i-j)) + penalty;
};
rep1(i,N){
int npj = pj;
for(int j=pj;j<i;j++){
double cost = getcost(j,i);
if(chmin(dp[i],P(dp[j].fs+cost,dp[j].sc+1))){
npj = j;
}else{
break;
}
}
pj = npj;
}
return dp[N];
};
double lb = 0, ub = 1e18;
rep(_,90){
double m = (lb+ub)/2;
auto p = f(m);
if(p.sc <= M) ub = m;
else lb = m;
}
auto p = f(ub);
show(ub);
show(p);
cout << p.fs - ub*p.sc << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
4 2 1 2 3 4
output:
6.19114712955711876674
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.59162536651412622746
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
1 1 1
output:
1.00000000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 1 100000
output:
316.22776601683796116049
result:
ok found '316.227766017', expected '316.227766017', error '0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
7 1 10 47 53 9 83 33 15
output:
41.83300132670377990962
result:
ok found '41.833001327', expected '41.833001327', error '0.000000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
8 5 138 1702 119 1931 418 1170 840 1794
output:
233.90165455194357946311
result:
ok found '233.901654552', expected '233.901654552', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
58 1 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983
output:
1355.26528768355910870014
result:
ok found '1355.265287684', expected '1355.265287684', error '0.000000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3876kb
input:
88 30 67117 31903 93080 85196 16438 97116 11907 72959 83651 41273 52873 81892 81468 51323 99992 58869 54258 7183 87358 90990 80596 41252 90769 82705 61434 8524 13575 10787 53950 96768 12062 34637 27806 70937 69653 28380 90236 3352 27537 3873 91006 89790 25369 91825 82734 5588 4539 74118 47098 84741 ...
output:
18791.61853815008362289518
result:
wrong answer 1st numbers differ - expected: '18791.4753541', found: '18791.6185382', error = '0.0000076'