답안 #1026153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026153 2024-07-17T16:04:50 Z snpmrnhlol Coin Collecting (JOI19_ho_t4) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5;
struct xy{
    ll x,y;
}v[N*2];
ll f[2];
int main(){
    ll n,m;
    ll ans = 0;
    cin>>n;
    for(ll i = 0;i < 2*n;i++){
        cin>>v[i].x>>v[i].y;
        v[i].x--;v[i].y--;
    }
    sort(v,v + n*2,[&](xy a,xy b){
         return a.x < b.x;
    });
    ll i = 0,j = 0;
    ll last = -1;
    while(i < n*2){
        j = i;
        f[0] = 0;f[1] = 0;
        if(last == 0)f[0]++;
        else if(last == 1)f[1]++;
        last = -1;
        while(j < n*2 && v[j].x == v[i].x){
            ans+=abs(v[j].x - j/2) + min(abs(v[j].y - 0),abs(v[j].y - 1));
            if(v[j].y <= 0)f[0]++;
            else f[1]++;
            j++;
        }
        if(f[0] > f[1]){
            f[0]-=f[1];
            ans+=f[0]/2;
            if(f[0]%2 == 1){
                last = 0;
            }
        }else{
            f[1]-=f[0];
            ans+=f[1]/2;
            if(f[1]%2 == 1){
                last = 1;
            }
        }

        ///i -> j - 1 fuck my wife
        i = j;
    }
    cout<<ans<<'\n';
    return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:10:10: warning: unused variable 'm' [-Wunused-variable]
   10 |     ll n,m;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -