답안 #548301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548301 2022-04-13T00:35:44 Z PikaQ Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
84 ms 14772 KB
#include<bits/stdc++.h>
//#define int ll
#define forn(i,n) for(int i=0;i<(n);i++)
#define Forn(i,n) for(int i=1;i<=(n);i++)
#define ll long long
#define pb push_back
#define F first
#define S second
#define vi vector<long long>
#define pii pair<int,int>
#define all(p) p.begin(),p.end()
#define st0(p) memset((p),0,sizeof(p))
#define sz(x) (x).size()
#define rz resize
using namespace std;

 
inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
 
void debug() {cout << endl;}
template <class T, class ...U> void debug(T a, U ... b) { cerr << a << " "; debug(b...);}
const int N = (int) 2e6+9;
const int INF = (int) 1e9 + 7;
int n,k;
struct FenwickTree{
	int t[N];
	void init(){
		for(auto &i : t) i = -INF;
	}
	void modify(int p,int v){
		for(;p <= n+1;p+=(p&-p)){
			t[p] = max(t[p],v);
		}
	}
	int query(int p){
		int res = -INF;
		for(;p;p-=(p&-p)) res = max(res,t[p]);
		return res;
	}
}bit;
void solve(){	
	cin >> n >> k;
	vi a(n);
	forn(i,n) cin >> a[i];
	for(int i = 1;i <= n;i++){
		a[i-1] -= k * i;
		a[i-1] *= -1;
	}
	vi dp(n);
	vi rk = a;
	rk.pb(0);
	sort(all(rk));
	rk.resize(unique(all(rk)) - rk.begin());
	forn(i,n){
		a[i] = upper_bound(all(rk),a[i]) - rk.begin();
	}
	bit.init();
	bit.modify(upper_bound(all(rk),0)-rk.begin(),0);
	forn(i,n){
		dp[i] = bit.query(a[i]) + 1;
		bit.modify(a[i],dp[i]);
	}
	cout << n - bit.query(n+1) << '\n';
}

signed main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 5 ms 8020 KB Output is correct
3 Correct 4 ms 8148 KB Output is correct
4 Correct 4 ms 8020 KB Output is correct
5 Correct 4 ms 8020 KB Output is correct
6 Correct 4 ms 8020 KB Output is correct
7 Correct 4 ms 8020 KB Output is correct
8 Correct 4 ms 8020 KB Output is correct
9 Correct 4 ms 8020 KB Output is correct
10 Correct 4 ms 8112 KB Output is correct
11 Correct 4 ms 8148 KB Output is correct
12 Correct 4 ms 8104 KB Output is correct
13 Correct 4 ms 8148 KB Output is correct
14 Correct 4 ms 8148 KB Output is correct
15 Correct 4 ms 8020 KB Output is correct
16 Correct 4 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 5 ms 8020 KB Output is correct
3 Correct 4 ms 8148 KB Output is correct
4 Correct 4 ms 8020 KB Output is correct
5 Correct 4 ms 8020 KB Output is correct
6 Correct 4 ms 8020 KB Output is correct
7 Correct 4 ms 8020 KB Output is correct
8 Correct 4 ms 8020 KB Output is correct
9 Correct 4 ms 8020 KB Output is correct
10 Correct 4 ms 8112 KB Output is correct
11 Correct 4 ms 8148 KB Output is correct
12 Correct 4 ms 8104 KB Output is correct
13 Correct 4 ms 8148 KB Output is correct
14 Correct 4 ms 8148 KB Output is correct
15 Correct 4 ms 8020 KB Output is correct
16 Correct 4 ms 8148 KB Output is correct
17 Correct 4 ms 8020 KB Output is correct
18 Correct 4 ms 8020 KB Output is correct
19 Correct 4 ms 8020 KB Output is correct
20 Correct 4 ms 8276 KB Output is correct
21 Correct 5 ms 8276 KB Output is correct
22 Correct 5 ms 8276 KB Output is correct
23 Correct 5 ms 8276 KB Output is correct
24 Correct 5 ms 8276 KB Output is correct
25 Correct 5 ms 8276 KB Output is correct
26 Correct 5 ms 8276 KB Output is correct
27 Correct 5 ms 8276 KB Output is correct
28 Correct 5 ms 8276 KB Output is correct
29 Correct 5 ms 8276 KB Output is correct
30 Correct 5 ms 8276 KB Output is correct
31 Correct 4 ms 8276 KB Output is correct
32 Correct 6 ms 8276 KB Output is correct
33 Correct 6 ms 8276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8020 KB Output is correct
2 Correct 4 ms 8020 KB Output is correct
3 Correct 4 ms 8020 KB Output is correct
4 Correct 4 ms 8276 KB Output is correct
5 Correct 5 ms 8276 KB Output is correct
6 Correct 5 ms 8276 KB Output is correct
7 Correct 5 ms 8276 KB Output is correct
8 Correct 5 ms 8276 KB Output is correct
9 Correct 5 ms 8276 KB Output is correct
10 Correct 5 ms 8276 KB Output is correct
11 Correct 5 ms 8276 KB Output is correct
12 Correct 5 ms 8276 KB Output is correct
13 Correct 5 ms 8276 KB Output is correct
14 Correct 5 ms 8276 KB Output is correct
15 Correct 4 ms 8276 KB Output is correct
16 Correct 6 ms 8276 KB Output is correct
17 Correct 6 ms 8276 KB Output is correct
18 Correct 4 ms 8020 KB Output is correct
19 Correct 5 ms 8020 KB Output is correct
20 Correct 4 ms 8148 KB Output is correct
21 Correct 4 ms 8020 KB Output is correct
22 Correct 4 ms 8020 KB Output is correct
23 Correct 4 ms 8020 KB Output is correct
24 Correct 4 ms 8020 KB Output is correct
25 Correct 4 ms 8020 KB Output is correct
26 Correct 4 ms 8020 KB Output is correct
27 Correct 4 ms 8112 KB Output is correct
28 Correct 4 ms 8148 KB Output is correct
29 Correct 4 ms 8104 KB Output is correct
30 Correct 4 ms 8148 KB Output is correct
31 Correct 4 ms 8148 KB Output is correct
32 Correct 4 ms 8020 KB Output is correct
33 Correct 4 ms 8148 KB Output is correct
34 Correct 5 ms 8276 KB Output is correct
35 Correct 5 ms 8252 KB Output is correct
36 Correct 5 ms 8188 KB Output is correct
37 Correct 5 ms 8276 KB Output is correct
38 Correct 4 ms 8276 KB Output is correct
39 Correct 5 ms 8276 KB Output is correct
40 Correct 5 ms 8276 KB Output is correct
41 Correct 5 ms 8276 KB Output is correct
42 Correct 5 ms 8276 KB Output is correct
43 Correct 5 ms 8276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8276 KB Output is correct
2 Correct 5 ms 8252 KB Output is correct
3 Correct 5 ms 8188 KB Output is correct
4 Correct 5 ms 8276 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 5 ms 8276 KB Output is correct
7 Correct 5 ms 8276 KB Output is correct
8 Correct 5 ms 8276 KB Output is correct
9 Correct 5 ms 8276 KB Output is correct
10 Correct 5 ms 8276 KB Output is correct
11 Correct 4 ms 8020 KB Output is correct
12 Correct 4 ms 8020 KB Output is correct
13 Correct 4 ms 8020 KB Output is correct
14 Correct 4 ms 8276 KB Output is correct
15 Correct 5 ms 8276 KB Output is correct
16 Correct 5 ms 8276 KB Output is correct
17 Correct 5 ms 8276 KB Output is correct
18 Correct 5 ms 8276 KB Output is correct
19 Correct 5 ms 8276 KB Output is correct
20 Correct 5 ms 8276 KB Output is correct
21 Correct 5 ms 8276 KB Output is correct
22 Correct 5 ms 8276 KB Output is correct
23 Correct 5 ms 8276 KB Output is correct
24 Correct 5 ms 8276 KB Output is correct
25 Correct 4 ms 8276 KB Output is correct
26 Correct 6 ms 8276 KB Output is correct
27 Correct 6 ms 8276 KB Output is correct
28 Correct 4 ms 8020 KB Output is correct
29 Correct 5 ms 8020 KB Output is correct
30 Correct 4 ms 8148 KB Output is correct
31 Correct 4 ms 8020 KB Output is correct
32 Correct 4 ms 8020 KB Output is correct
33 Correct 4 ms 8020 KB Output is correct
34 Correct 4 ms 8020 KB Output is correct
35 Correct 4 ms 8020 KB Output is correct
36 Correct 4 ms 8020 KB Output is correct
37 Correct 4 ms 8112 KB Output is correct
38 Correct 4 ms 8148 KB Output is correct
39 Correct 4 ms 8104 KB Output is correct
40 Correct 4 ms 8148 KB Output is correct
41 Correct 4 ms 8148 KB Output is correct
42 Correct 4 ms 8020 KB Output is correct
43 Correct 4 ms 8148 KB Output is correct
44 Correct 49 ms 12748 KB Output is correct
45 Correct 84 ms 14700 KB Output is correct
46 Correct 73 ms 14772 KB Output is correct
47 Correct 72 ms 14648 KB Output is correct
48 Correct 58 ms 13760 KB Output is correct
49 Correct 53 ms 13896 KB Output is correct
50 Correct 37 ms 14768 KB Output is correct
51 Correct 34 ms 14768 KB Output is correct
52 Correct 36 ms 13616 KB Output is correct
53 Correct 32 ms 14000 KB Output is correct
54 Correct 58 ms 13868 KB Output is correct
55 Correct 55 ms 13892 KB Output is correct