답안 #548298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548298 2022-04-13T00:32:34 Z PikaQ Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 6996 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) 2e5+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++){
			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 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1864 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1864 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1868 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1864 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1864 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1868 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 8 ms 2004 KB Output is correct
21 Correct 11 ms 2004 KB Output is correct
22 Correct 16 ms 2072 KB Output is correct
23 Correct 12 ms 2072 KB Output is correct
24 Correct 14 ms 2172 KB Output is correct
25 Correct 13 ms 2076 KB Output is correct
26 Correct 12 ms 2036 KB Output is correct
27 Correct 21 ms 2004 KB Output is correct
28 Correct 22 ms 2056 KB Output is correct
29 Correct 12 ms 2004 KB Output is correct
30 Correct 13 ms 2004 KB Output is correct
31 Correct 20 ms 2032 KB Output is correct
32 Correct 12 ms 2000 KB Output is correct
33 Correct 12 ms 2004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 8 ms 2004 KB Output is correct
5 Correct 11 ms 2004 KB Output is correct
6 Correct 16 ms 2072 KB Output is correct
7 Correct 12 ms 2072 KB Output is correct
8 Correct 14 ms 2172 KB Output is correct
9 Correct 13 ms 2076 KB Output is correct
10 Correct 12 ms 2036 KB Output is correct
11 Correct 21 ms 2004 KB Output is correct
12 Correct 22 ms 2056 KB Output is correct
13 Correct 12 ms 2004 KB Output is correct
14 Correct 13 ms 2004 KB Output is correct
15 Correct 20 ms 2032 KB Output is correct
16 Correct 12 ms 2000 KB Output is correct
17 Correct 12 ms 2004 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1864 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
26 Correct 1 ms 1864 KB Output is correct
27 Correct 1 ms 1876 KB Output is correct
28 Correct 1 ms 1876 KB Output is correct
29 Correct 1 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1868 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 12 ms 2004 KB Output is correct
35 Correct 12 ms 2068 KB Output is correct
36 Correct 12 ms 2004 KB Output is correct
37 Correct 12 ms 2040 KB Output is correct
38 Correct 25 ms 2004 KB Output is correct
39 Correct 22 ms 2004 KB Output is correct
40 Correct 19 ms 2052 KB Output is correct
41 Correct 22 ms 2000 KB Output is correct
42 Correct 12 ms 2044 KB Output is correct
43 Correct 12 ms 2004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2004 KB Output is correct
2 Correct 12 ms 2068 KB Output is correct
3 Correct 12 ms 2004 KB Output is correct
4 Correct 12 ms 2040 KB Output is correct
5 Correct 25 ms 2004 KB Output is correct
6 Correct 22 ms 2004 KB Output is correct
7 Correct 19 ms 2052 KB Output is correct
8 Correct 22 ms 2000 KB Output is correct
9 Correct 12 ms 2044 KB Output is correct
10 Correct 12 ms 2004 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 8 ms 2004 KB Output is correct
15 Correct 11 ms 2004 KB Output is correct
16 Correct 16 ms 2072 KB Output is correct
17 Correct 12 ms 2072 KB Output is correct
18 Correct 14 ms 2172 KB Output is correct
19 Correct 13 ms 2076 KB Output is correct
20 Correct 12 ms 2036 KB Output is correct
21 Correct 21 ms 2004 KB Output is correct
22 Correct 22 ms 2056 KB Output is correct
23 Correct 12 ms 2004 KB Output is correct
24 Correct 13 ms 2004 KB Output is correct
25 Correct 20 ms 2032 KB Output is correct
26 Correct 12 ms 2000 KB Output is correct
27 Correct 12 ms 2004 KB Output is correct
28 Correct 1 ms 1876 KB Output is correct
29 Correct 1 ms 1876 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1876 KB Output is correct
32 Correct 1 ms 1864 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 1 ms 1876 KB Output is correct
35 Correct 1 ms 1876 KB Output is correct
36 Correct 1 ms 1864 KB Output is correct
37 Correct 1 ms 1876 KB Output is correct
38 Correct 1 ms 1876 KB Output is correct
39 Correct 1 ms 1876 KB Output is correct
40 Correct 1 ms 1876 KB Output is correct
41 Correct 1 ms 1868 KB Output is correct
42 Correct 1 ms 1876 KB Output is correct
43 Correct 1 ms 1876 KB Output is correct
44 Execution timed out 1088 ms 6996 KB Time limit exceeded
45 Halted 0 ms 0 KB -