Submission #845424


Source Code Expand

Copy
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

template<class T> bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }
template<class T> bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }

void solve() {
  int n;
  cin >> n;
  vi a(n);
  forn(i, n) cin >> a[i];
  vi b0((n+1)/2), b1(n/2);
  forn(i, n) if(i&1) b1[i/2] = a[i]; else b0[i/2] = a[i];
  sort(all(b0));
  sort(all(b1));
  sort(all(a));
  int r = 0;
  for (int x: b1) {
    int j = lower_bound(all(a), x) - a.begin();
    if (j % 2 == 0)
      r += 1;
  }
  cout << r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}

Submission Info

Submission Time
Task C - BBuBBBlesort!
User gchebanov
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1693 Byte
Status AC
Exec Time 49 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 24
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 49 ms 1024 KB
02.txt AC 49 ms 1024 KB
03.txt AC 49 ms 1024 KB
04.txt AC 49 ms 1024 KB
05.txt AC 44 ms 1024 KB
06.txt AC 45 ms 1024 KB
07.txt AC 48 ms 1024 KB
08.txt AC 29 ms 1024 KB
09.txt AC 29 ms 1024 KB
10.txt AC 27 ms 1024 KB
11.txt AC 29 ms 1024 KB
12.txt AC 29 ms 1024 KB
13.txt AC 28 ms 1024 KB
14.txt AC 45 ms 1024 KB
15.txt AC 44 ms 1024 KB
16.txt AC 45 ms 1024 KB
17.txt AC 45 ms 1024 KB
18.txt AC 4 ms 256 KB
19.txt AC 4 ms 256 KB
20.txt AC 4 ms 256 KB
21.txt AC 4 ms 256 KB
22.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB