제출 #280375

#제출 시각아이디문제언어결과실행 시간메모리
280375CaroLindaArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms288 KiB
#include <bits/stdc++.h> #include "shoes.h" #define sz(x) (int)x.size() #define mkt make_tuple #define lp(i,a,b) for(int i = a ; i < b ; i++ ) #define ff first #define ss second #define eb emplace_back #define ll long long #define mk make_pair #define pii pair<int,int> #define debug printf #define all(x) x.begin(),x.end() const int MAXN = 1e5+10 ; using namespace std ; int freq[MAXN][2] ; /* 6 -2 2 -2 2 -2 2 */ long long count_swaps(vector<int> v) { ll ans = 0LL ; for(int i = 0 ; i < sz(v) ; i++ ) { //debug("%d %d\n" , freq[ abs(v[i]) ][0] , freq[ abs(v[i]) ][1] ) ; if( v[i] < 0 ) { if( freq[ -v[i] ][1] > 0 ) freq[ -v[i] ][1] -- , ans += (ll)i ; else freq[ -v[i] ][0]++ , ans -= (ll)i , ans-- ; } else { if( freq[ v[i] ][0] > 0) freq[ v[i] ][0]-- , ans += (ll)i ; else freq[v[i]][1]++ , ans -= (ll)i ; } } return ans ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...