牛客練習賽56 C

2021-10-01 18:50:15 字數 988 閱讀 6958

預處理出該序列中的每個數是第幾大的,然後依次按照大小插入到樹狀陣列中,

沒插入乙個數字,就判斷現在在陣列中的數比當前數小的數有多少個,讓後逐層更新一下,更新k層,最後把低k層的數加起來即可。

#include

#include

using

namespace std;

typedef

long

long ll;

const

int n=

600500

;const ll mod=

998244353

;ll c[n][15

],ans[n][15

];int a[n]

,b[n]

;int n,k;

void

add(

int i,

int x,

int y)

ll ask

(int i,

int x)

intmain()

sort

(b+1

,b+n+1)

;int len=

unique

(b+1

,b+n+1)

-b-1

;for

(int i=

1; i<=n;

++i)

ll anss=0;

for(

int i=

1; i<=n;

++i)

anss=

(anss+ans[i]

[k])

%mod;

}printf

("%lld\n"

,anss)

;return0;

}

好狠一道題,活生生改了我一上午,同樣的**,同時交好幾發,三分之一過,三分之二超時,最後把二維陣列的的兩個維度換一下,快了將近一半時間,不知道是玄學還是有什麼依據,太菜了啊。

牛客練習賽56 C

思路 先依次預處理每個數字是第幾大,然後依次按大小插入到樹狀陣列中,每插入乙個數判斷現在陣列中比當前數小的有多少個,逐層更新下去,更新到k層,把k層數值加起來即可 include include include using namespace std typedef long long ll con...

牛客練習賽9

時間限制 c c 1秒,其他語言2秒 空間限制 c c 32768k,其他語言65536k 64bit io format lld 珂朵莉想每天都給威廉送禮物,於是她準備了n個自己的本子 她想送最多的天數,使得每天至少送乙個本子,但是相鄰兩天送的本子個數不能相同 珂朵莉最多送幾天禮物呢 第一行乙個整...

牛客練習賽15

時間限制 c c 2秒,其他語言4秒 空間限制 c c 262144k,其他語言524288k 64bit io format lld 第一次期中考終於結束啦!沃老師是個語文老師,他在評學生的作文成績時,給每位學生的分數都是乙個小於10的非負小數。amy 8.99999999999999999999...