제출 #1328943

#제출 시각아이디문제언어결과실행 시간메모리
1328943boclobanchatCoin Collecting (JOI19_ho_t4)C++20
0 / 100
0 ms344 KiB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;
const long long INF=1e18;
pair<long long,long long> A[MAXN];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    long long ans=0,cntx=0,cnty=0;
    for(int i=1;i<=n*2;i++)
    {
    	cin>>A[i].first>>A[i].second;
    	if(A[i].second<=1) cntx++,ans+=1-A[i].second;
    	else cnty++,ans+=A[i].second-2;
	}
    sort(A+1,A+n*2+1);
    for(int i=1;i<=n*2;i++) ans+=abs(A[i].first-(i+1)/2);
    cout<<ans+max(cntx,cnty)-n;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...