Submission #375249

# Submission time Handle Problem Language Result Execution time Memory
375249 2021-03-09T05:27:02 Z NurstanDuisengaliev Po (COCI21_po) C++14
10 / 70
1000 ms 14828 KB
// Nurstan Duisengaliev(REALBOY)
// не, не надо меня узнавать 
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")*/                   
      
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define pll pair <ll, ll>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int n;
int a[N];
void compress () {
	set <int> s;
	map <int, int> m;
	for (int i = 1; i <= n; i ++) s.in (a[i]);
	int pos = 1;
	for (auto it : s) {
		m[it] = pos ++;
	}
	for (int i = 1; i <= n; i ++) a[i] = m[a[i]];
}
vector <int> g[N];
void solve () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];              
	}
	compress (); 
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
	    bool check = 0;
		for (int j = 1; j <= n; j ++) {
			if (a[j] == i) {
				if (check == 0) {
					ans ++;
					check = 1;
				}
				a[j] = 0;				
			}	
			else {
				if (a[j] == 0) check = 0;
			}
		}
	}
	cout << ans;
	/*for (int i = 1; i <= n; i ++) {
		g[a[i]].pb (i);
	}
	for (int i = 1; i <= n; i ++) {
		ans ++;
		for (int j = 1; j < sz (g[i]); j ++) {
			int pos = g[i][j];
			if (a[pos - 1] < a[i]) {
				ans ++;
			}
		}
	}   */
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	                                    
}

Compilation message

Main.cpp:81:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main () {
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Incorrect 4 ms 4972 KB Output isn't correct
3 Incorrect 4 ms 4972 KB Output isn't correct
4 Execution timed out 1095 ms 5228 KB Time limit exceeded
5 Execution timed out 1064 ms 5356 KB Time limit exceeded
6 Execution timed out 1071 ms 10092 KB Time limit exceeded
7 Execution timed out 1093 ms 14828 KB Time limit exceeded