| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 153821 | arnold518 | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N;
int A[3][MAXN+10];
ll ans;
int main()
{
int i, j;
scanf("%d", &N);
for(i=1; i<=2*N; i++)
{
int x, y;
scanf("%d%d", &x, &y);
if(x<1) ans+=1-x, x=1;
if(x>N) ans+=x-N, x=N;
if(y<1) ans+=1-y, y=1;
if(y>2) ans+=y-2, y=2;
A[y][x]++;
}
for(j=1; j<=N; j++) printf("%d ", A[1][j]); printf("\n");
for(j=1; j<=N; j++) printf("%d ", A[2][j]); printf("\n");
printf("%lld\n", ans);
for(i=1; i<N; i++)
{
if(A[1][i]<1 && A[2][i]>=1)
{
if(A[1][i]+A[2][i]>=2)
{
ans+=1-A[1][i];
A[2][i]-=1-A[1][i];
A[1][i]=1;
}
else
{
ans+=A[2][i]-1;
A[1][i]+=A[2][i]-1;
A[2][i]=1;
}
}
if(A[2][i]<1 && A[1][i]>=1)
{
if(A[1][i]+A[2][i]>=2)
{
ans+=1-A[2][i];
A[1][i]-=1-A[2][i];
A[2][i]=1;
}
else
{
ans+=A[1][i]-1;
A[2][i]+=A[1][i]-1;
A[1][i]=1;
}
}
if(A[1][i]>=1)
{
ans+=A[1][i]-1;
A[1][i+1]+=A[1][i]-1; A[1][i]=1;
}
else
{
ans+=1-A[1][i];
A[1][i+1]+=A[1][i]-1; A[1][i]=1;
}
if(A[2][i]>=1)
{
ans+=A[2][i]-1;
A[2][i+1]+=A[2][i]-1; A[2][i]=1;
}
else
{
ans+=1-A[2][i];
A[2][i+1]+=A[2][i]-1; A[2][i]=1;
}
}
ans+=abs(A[1][N]-1);
printf("%lld", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
