답안 #560007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560007 2022-05-11T02:56:23 Z karrigan Coin Collecting (JOI19_ho_t4) C++14
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
using namespace std;
const int maxn=1e6;
using ll=long long int;
int a[100009][3];
int main()
{
    fastio
    //freopen(".INP","r",stdin);
    //freopen(".OUT","w",stdout);
    //solve();
    int n;
    cin>>n;
    long long ans=0;
    for (int i=1;i<=n*2;i++){
        long long x,y;
        cin>>x>>y;
        long long x2,y2;
        if (x>=n)x2=n;
        else if (x<=1)x2=1;
        else x2=x;
        if (y>=2)y2=2;
        else y2=1;
        ans=ans+abs(x-x2)+abs(y-y2);
        a[x2][y2]++;
        //cout<<x2<<" "<<y2<<'\n';
    }
    for (int i=1;i<n;i++){
        a[i][1]--;
        a[i][2]--;
        if (a[i][2]<0){
            a[i][1]-=abs(a[i][2]);
            a[i][2]=0;;
            ans+=abs(a[i][2]);
        }
        if (a[i][1]<0){
            a[i][2]-=abs(a[i][1]);
            a[i][1]=0;
            ans+=abs(a[i][1]);
        }
        if (a[i][1]>0){
        a[i+1][1]+=a[i][1];
        ans++;
        }
        if (a[i][2]>0){
        a[i+1][2]+=a[i][2];
        ans++;
        }
    }
    for (int i=n;i<=n;i++){
        a[i][1]--;
        a[i][2]--;
        if (a[i][2]<0){
            a[i][1]--;
            a[i][2]++;;
            ans++;
        }
        if (a[i][1]<0){
            a[i][2]--;
            a[i][1]++;
            ans++;
        }
        //cout<<a[i][1]<<" "<<a[i][2]<<'\n';
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -