Submission #691761

# Submission time Handle Problem Language Result Execution time Memory
691761 2023-01-31T14:10:00 Z tolbi Money (IZhO17_money) C++17
45 / 100
1500 ms 93376 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#ifdef LOCAL
	#include "23.h"
#endif
#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 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;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
struct SegTree{
	vector<int> segtree;
	SegTree(int n){
		n++;
		segtree.resize(tol(ceil(log2(n)+1))-1,0ll);
	}
	void update(int node){
		node+=segtree.size()/2;
		segtree[node]++;
		while(node){
			node=(node-1)/2;
			segtree[node]++;
		}
	}
	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 (r<tarl || l>tarr) return 0;
		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 lnode+rnode;
	}
};
vector<int> compress(vector<int> arr){
	vector<int> barr = arr;
	map<int,int> mp;
	sortarr(barr);
	int ind = 1;
	for (int i = 0; i < arr.size(); i++){
		if (mp[barr[i]]) continue;
		mp[barr[i]]=ind++;
	}
	for (int i = 0; i < arr.size(); ++i)
	{
		arr[i]=mp[arr[i]];
	}
	return arr;
}
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		deci(n);
		vint(arr(n));
		cinarr(arr);
		arr=compress(arr);
		SegTree segtree(n+5);
		int ans = n;
		segtree.update(arr[0]);
		vector<int> barr=arr;
		vector<int> pusa;
		for (int i = 1; i < n; i++){
			pusa.push_back(arr[i]);
			if (arr[i]>=barr[i-1]){
				if (segtree.query(arr[i-1]+1,arr[i]-1)==0){
					ans--;
					arr[i]=arr[i-1];
				}
				else {
					while (pusa.size()){
						segtree.update(pusa.back());
						pusa.pop_back();
					}
				}
			}
			else {
				while (pusa.size()){
					segtree.update(pusa.back());
					pusa.pop_back();
				}
			}
		}
		cout<<ans<<endl;
	}
}

Compilation message

money.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
money.cpp: In function 'std::vector<long long int> compress(std::vector<long long int>)':
money.cpp:62:20: 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]
   62 |  for (int i = 0; i < arr.size(); i++){
      |                  ~~^~~~~~~~~~~~
money.cpp:66:20: 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]
   66 |  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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 324 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 324 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 324 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 324 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 0 ms 328 KB Output is correct
38 Correct 1 ms 320 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 324 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 324 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 324 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 0 ms 328 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 121 ms 19216 KB Output is correct
40 Correct 213 ms 34432 KB Output is correct
41 Correct 101 ms 17196 KB Output is correct
42 Correct 98 ms 16468 KB Output is correct
43 Correct 63 ms 9804 KB Output is correct
44 Correct 295 ms 39132 KB Output is correct
45 Correct 262 ms 39208 KB Output is correct
46 Correct 255 ms 39228 KB Output is correct
47 Correct 271 ms 39244 KB Output is correct
48 Correct 256 ms 39228 KB Output is correct
49 Correct 1002 ms 55256 KB Output is correct
50 Correct 967 ms 55176 KB Output is correct
51 Correct 1014 ms 55220 KB Output is correct
52 Correct 1000 ms 55252 KB Output is correct
53 Correct 1020 ms 55312 KB Output is correct
54 Correct 1006 ms 55136 KB Output is correct
55 Execution timed out 1560 ms 93376 KB Time limit exceeded
56 Halted 0 ms 0 KB -