Submission #375249

#TimeUsernameProblemLanguageResultExecution timeMemory
375249NurstanDuisengalievPo (COCI21_po)C++14
10 / 70
1095 ms14828 KiB
// 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 (stderr)

Main.cpp:81:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main () {
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...