結果

問題 No.3072 Sum of sqrt(x)
ユーザー chocoruskchocorusk
提出日時 2020-09-12 22:24:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
OLE  
実行時間 -
コード長 1,600 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 133,568 KB
実行使用メモリ 51,408 KB
最終ジャッジ日時 2023-08-30 19:21:01
合計ジャッジ時間 51,665 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
36,240 KB
testcase_01 AC 10 ms
36,532 KB
testcase_02 AC 11 ms
36,336 KB
testcase_03 AC 20 ms
36,496 KB
testcase_04 AC 10 ms
36,404 KB
testcase_05 AC 10 ms
36,276 KB
testcase_06 AC 11 ms
36,340 KB
testcase_07 OLE -
testcase_08 AC 661 ms
51,408 KB
testcase_09 OLE -
testcase_10 OLE -
testcase_11 OLE -
testcase_12 OLE -
testcase_13 OLE -
testcase_14 OLE -
testcase_15 OLE -
testcase_16 OLE -
testcase_17 OLE -
testcase_18 OLE -
testcase_19 OLE -
testcase_20 OLE -
testcase_21 OLE -
testcase_22 OLE -
testcase_23 OLE -
testcase_24 OLE -
testcase_25 OLE -
testcase_26 OLE -
testcase_27 OLE -
testcase_28 OLE -
testcase_29 OLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int n;
    scanf("%d", &n);
    vector<pair<ll, int>> v(n);
    for(int i=0; i<n; i++){
        ll x;
        scanf("%lld", &x);
        v[i]=make_pair(x, i);
    }
    sort(v.begin(), v.end());
    long double seg[1<<21]={};
    int sz=1;
    while(sz<n) sz<<=1;
    auto add=[&](int l, int r, long double x){
        l+=sz, r+=sz;
        for(;l<r; l>>=1, r>>=1){
            if(r&1) seg[--r]+=x;
            if(l&1) seg[l++]+=x;
        }
    };
    auto calc=[&](int i){
        i+=sz;
        long double ret=seg[i];
        while(i>1){
            i>>=1;
            ret+=seg[i];
        }
        return ret;
    };
    for(int i=0; i<n; i++){
        add(v[i].second, n, sqrt((long double)v[i].first));
    }
    for(int i=0; i<n; i++){
        long double ans=calc(i);
        if(ans<1e3) printf("%.17Lf\n", ans);
        else if(ans<1e6) printf("%.14Lf\n", ans);
        else if(ans<1e9) printf("%.11Lf\n", ans);
        else if(ans<1e12) printf("%.8Lf\n", ans);
        else printf("%.5Lf\n", ans);
    }
    return 0;
}
0