| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 127707 | arnold518 | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 760 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 = 1000;
const ll INF = 1e17;
struct Point
{
ll x, y;
bool operator < (const Point& p) { return x<p.x; }
};
ll dist(Point p, Point q) { return abs(p.x-q.x)+abs(p.y-q.y); }
int N;
Point coin[MAXN+10];
ll dp[MAXN+10][MAXN+10];
int main()
{
int i, j;
scanf("%d", &N);
for(i=1; i<=2*N; i++) scanf("%lld%lld", &coin[i].x, &coin[i].y);
sort(coin+1, coin+2*N+1);
for(i=0; i<=N; i++) for(j=0; j<=N; j++)
{
if(i==0 && j==0) continue;
dp[i][j]=INF;
if(i!=0) dp[i][j]=min(dp[i][j], dist(coin[i+j], {i, 1})+dp[i-1][j]);
if(j!=0) dp[i][j]=min(dp[i][j], dist(coin[i+j], {j, 2})+dp[i][j-1]);
}
printf("%lld", dp[N][N]);
}
컴파일 시 표준 에러 (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... | ||||
