Submission #492900

# Submission time Handle Problem Language Result Execution time Memory
492900 2021-12-09T16:03:05 Z Biaz Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<double,int>
#define ALL(i) i.begin(),i.end()
#define gcd(i,j) __gcd(i,j)
#define fi first
#define se second
#define eps 0.00000001
#define ist insert
#define DNE nullptr
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
int max(int x,int y){return x>=y?x:y;}
int min(int x,int y){return x>=y?y:x;}
using namespace std;
typedef int ll;
const int N=200005;
const int M=1000005;
const int MOD=1000000007;//998244353;
const int INF=1000000000000000000;//2147483647;
 
int n,ans;
pi p[N];
inline void sol(){
    cin >>n;
    for (int i=0;i<2*n;i++)
        cin >>p[i].fi>>p[i].se;
    sort(p,p+2*n,[](pi l,pi r){
        return l.fi!=r.fi?l.fi<r.fi:l.se<r.se;
    });
    for (int i=0;i<2*n;i+=2){
        int j=i+1,d=i/2+1;;
        ans+=min(abs(d-p[i].fi)+abs(1-p[i].se)+abs(d-p[j].fi)+abs(2-p[j].se),abs(d-p[j].fi)+abs(1-p[j].se)+abs(d-p[i].fi)+abs(2-p[i].se));
    }
    cout <<ans<<'\n';
}
 
signed main(){
    Nanase_Kurumi_aka_menhera_chan_is_mine
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -