QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702412 | #9540. Double 11 | ucup-team159# | WA | 3ms | 3992kb | C++23 | 3.8kb | 2024-11-02 15:56:30 | 2024-11-02 15:56:30 |
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;
}
}
for(int j=pj;j<min(pj+10,i);j++){
double cost = getcost(j,i);
chmin(dp[i],P(dp[j].fs+cost,dp[j].sc+1));
}
pj = npj-2; chmax(pj,0);
}
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*M << endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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: 3924kb
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: 3992kb
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: 3840kb
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: 3912kb
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: 3980kb
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: 1ms
memory: 3860kb
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: 0
Accepted
time: 0ms
memory: 3900kb
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.47535409410193096846
result:
ok found '18791.475354094', expected '18791.475354094', error '0.000000000'
Test #9:
score: -100
Wrong Answer
time: 3ms
memory: 3896kb
input:
987 59 5209 1618 7129 7700 893 6647 8231 3314 9844 1347 6789 2711 3968 7416 5864 9190 9564 8874 7357 2087 530 8754 7935 6772 3475 8206 2898 2717 9252 8686 6604 5188 7451 9977 9366 7618 6294 6454 3919 3232 8164 8403 8617 2191 5257 626 8554 1952 1727 4759 205 9453 3312 9387 4798 7774 7005 8892 3570 50...
output:
66076.38252977613592520356
result:
wrong answer 1st numbers differ - expected: '66075.5085871', found: '66076.3825298', error = '0.0000132'