Submission #655672

# Submission time Handle Problem Language Result Execution time Memory
655672 2022-11-05T08:27:35 Z tolbi Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
141 ms 21620 KB
//#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define ayahya() chrono::steady_clock().now().time_since_epoch().count()
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
using namespace std;
struct SegTree{
	vector<int> segtree;
	SegTree(int n){
		segtree.resize(tol(ceil(log2(n)+1))-1,0ll);
	}
	int query(int tarl, int tarr, int l = 0, int r = -1, int node = 0){
		if (r==-1) r = segtree.size()/2;
		if (l>=tarl && r<=tarr) return segtree[node];
		if (l>tarr || r<tarl) return 0ll;
		int mid = l+(r-l)/2;
		int lnode = query(tarl, tarr, l, mid, node*2+1);
		int rnode = query(tarl, tarr, mid+1, r, node*2+2);
		return max(lnode, rnode);
	}
	void update(int node, int val){
		node+=segtree.size()/2;
		segtree[node]=max(segtree[node],val);
		while (node){
			node=(node-1)/2;
			segtree[node]=max(segtree[node*2+1],segtree[node*2+2]);
		}
	}
};
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		deci(n);deci(k);
		vint(arr(n));
		cinarr(arr);
		for (int i = 0; i < n; i++){
			arr[i]-=(i+1)*k;
			arr[i]=-arr[i];
		}
		vector<int> narr;
		for (int i = 0; i < arr.size(); i++){
			if (arr[i]>=0) narr.push_back(arr[i]);
		}
		arr.clear();
		arr=narr;
		map<int,int> mp;
		int indi = 1;
		vector<int> barr=arr;
		sortarr(barr);
		for (int i = 0; i < (int)barr.size(); i++){
			if (mp[barr[i]]) continue;
			mp[barr[i]]=indi++;
		}
		for (int i = 0; i < (int)arr.size(); i++){
			arr[i]=mp[arr[i]];
		}
		SegTree segtree(indi+5);
		int ans = 0;
		for (int i = 0; i < (int)arr.size(); i++){
			int val = segtree.query(0,arr[i])+1ll;
			segtree.update(arr[i],val);
			ans=max(ans,val);
		}
		cout<<n-ans<<endl;
	}
}

Compilation message

triusis.cpp: In function 'int32_t main()':
triusis.cpp:71:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for (int i = 0; i < arr.size(); i++){
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 288 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 288 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 852 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 852 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 2 ms 852 KB Output is correct
26 Correct 3 ms 872 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 4 ms 852 KB Output is correct
30 Correct 3 ms 784 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 3 ms 852 KB Output is correct
33 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 3 ms 852 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 3 ms 852 KB Output is correct
8 Correct 3 ms 852 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 3 ms 872 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 3 ms 784 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 288 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 2 ms 596 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 3 ms 852 KB Output is correct
43 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 3 ms 852 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 852 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Correct 2 ms 852 KB Output is correct
20 Correct 3 ms 872 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 4 ms 852 KB Output is correct
24 Correct 3 ms 784 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 3 ms 852 KB Output is correct
27 Correct 3 ms 852 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 288 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 127 ms 21620 KB Output is correct
45 Correct 24 ms 1876 KB Output is correct
46 Correct 104 ms 11768 KB Output is correct
47 Correct 101 ms 11820 KB Output is correct
48 Correct 129 ms 21332 KB Output is correct
49 Correct 127 ms 21572 KB Output is correct
50 Correct 27 ms 4300 KB Output is correct
51 Correct 26 ms 5068 KB Output is correct
52 Correct 91 ms 13280 KB Output is correct
53 Correct 14 ms 1876 KB Output is correct
54 Correct 132 ms 21564 KB Output is correct
55 Correct 141 ms 21472 KB Output is correct