提出 #48113944


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_A=1e6;
const int inf=1e9+7;
void solve(){
    int N;
    cin>>N;
    vector<int>A(N);
    vector<ll>sum((MAX_A+5)<<2);
    function<void(int,int,int,int)> add=[&](int o,int l,int r,int val){
        if(l==r){
            sum[o]+=val;
            return;
        }
        int mid=l+r>>1;
        if(val<=mid) add(o<<1,l,mid,val);
        else add(o<<1|1,mid+1,r,val);
        sum[o]=sum[o<<1]+sum[o<<1|1];
    };
    function<ll(int,int,int,int)> query=[&](int o,int l,int r,int val){
        if(l>=val){
            return sum[o];
        }
        int mid=l+r>>1;
        ll ans=0;
        if(val<=mid) ans+=query(o<<1,l,mid,val);
        ans+=query(o<<1|1,mid+1,r,val);
        return ans;
    };
    for(auto &x:A){
        cin>>x;
        add(1,1,MAX_A,x);
    }
    for(int i=0;i<N;++i){
        cout<<query(1,1,MAX_A,A[i]+1)<<" \n"[i==N-1];
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

提出情報

提出日時
問題 C - Sum of Numbers Greater Than Me
ユーザ PotremZ
言語 C++ 20 (gcc 12.2)
得点 300
コード長 1075 Byte
結果 AC
実行時間 140 ms
メモリ 35024 KiB

コンパイルエラー

Main.cpp: In lambda function:
Main.cpp:16:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   16 |         int mid=l+r>>1;
      |                 ~^~
Main.cpp: In lambda function:
Main.cpp:25:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   25 |         int mid=l+r>>1;
      |                 ~^~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 21
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 13 ms 34224 KiB
random_01.txt AC 134 ms 34948 KiB
random_02.txt AC 91 ms 34544 KiB
random_03.txt AC 137 ms 35024 KiB
random_04.txt AC 140 ms 34928 KiB
random_05.txt AC 139 ms 34896 KiB
random_06.txt AC 33 ms 34404 KiB
random_07.txt AC 138 ms 34960 KiB
random_08.txt AC 118 ms 34968 KiB
random_09.txt AC 138 ms 34944 KiB
random_10.txt AC 30 ms 34452 KiB
random_11.txt AC 88 ms 34916 KiB
random_12.txt AC 75 ms 35012 KiB
random_13.txt AC 77 ms 34992 KiB
random_14.txt AC 116 ms 35000 KiB
random_15.txt AC 116 ms 35004 KiB
random_16.txt AC 102 ms 34948 KiB
random_17.txt AC 101 ms 34960 KiB
sample_01.txt AC 13 ms 34180 KiB
sample_02.txt AC 13 ms 34128 KiB
sample_03.txt AC 13 ms 34136 KiB