Submission #845978
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
fprintf( stderr, \
fmt "\n", \
##__VA_ARGS__ \
)
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const double EPS = 1e-10;
double zero(double d) {
return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
return os << '(' << p.first << ',' << p.second << ')';
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
os << '[';
rep(i, a.size()) os << (i ? " " : "") << a[i];
return os << ']';
}
string toString(int i) {
stringstream ss;
ss << i;
return ss.str();
}
const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
ll res = 1ll;
ll x = a;
while (k != 0) {
if ((k & 1) == 1)
res = (res * x) % M;
x = (x * x) % M;
k >>= 1;
}
return res;
}
struct prepare {
prepare() {
cout.setf(ios::fixed, ios::floatfield);
cout.precision(8);
ios_base::sync_with_stdio(false);
}
} _prepare;
int main() {
int N;
cin >> N;
vector<pii> A(N);
rep(i, N) {
int t;
cin >> t;
A[i] = mp(t, i);
}
sort(all(A));
vi d(N);
ll ans = 0;
rep(i, N) {
d[i] = abs(A[i].second - i);
if(d[i] % 2 != 0)
ans++;
}
cout << (int)ceil((double)ans/2) << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - BBuBBBlesort! |
User |
palpal |
Language |
C++11 (GCC 4.8.1) |
Score |
600 |
Code Size |
2498 Byte |
Status |
AC |
Exec Time |
40 ms |
Memory |
1536 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
600 / 600 |
Status |
|
|
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 |
40 ms |
1536 KB |
02.txt |
AC |
38 ms |
1408 KB |
03.txt |
AC |
39 ms |
1408 KB |
04.txt |
AC |
39 ms |
1408 KB |
05.txt |
AC |
34 ms |
1408 KB |
06.txt |
AC |
35 ms |
1408 KB |
07.txt |
AC |
34 ms |
1408 KB |
08.txt |
AC |
24 ms |
1408 KB |
09.txt |
AC |
24 ms |
1408 KB |
10.txt |
AC |
23 ms |
1408 KB |
11.txt |
AC |
23 ms |
1408 KB |
12.txt |
AC |
24 ms |
1408 KB |
13.txt |
AC |
24 ms |
1408 KB |
14.txt |
AC |
34 ms |
1408 KB |
15.txt |
AC |
35 ms |
1408 KB |
16.txt |
AC |
34 ms |
1408 KB |
17.txt |
AC |
34 ms |
1408 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 |