| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 361660 | Dymo | 도장 모으기 (JOI14_stamps) | C++14 | 153 ms | 35912 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn =3e3+10;
const ll mod=1e9+7;
const ll base=1e9;
ll dp[maxn][maxn];
ll stayleft[maxn];
ll stayright[maxn];
ll toleft[maxn];
ll toright[maxn];
ll n, t;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("A.inp","r"))
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
}
cin>> n>> t;
for (int i=0;i<n;i++)
{
ll u, v, d, e;
cin>> u>> v>> d>> e;
stayleft[i]=d+e;
stayright[i]=u+v;
toleft[i]=u+e;
toright[i]=v+d;
}
for (int i=0;i<=n;i++)
{
for (int j=0;j<=n;j++)
{
dp[i][j]=base;
}
}
dp[0][0]=0;
for (ll i=0;i<n;i++)
{
for (ll j=0;j<=n;j++)
{
if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]-2*t*i+toright[i]);
}
for (ll j=n;j>=0;j--)
{
if (j<n) dp[i][j]=min(dp[i][j],dp[i][j+1]+2*t*i+toleft[i]);
}
for (ll j=0;j<=n;j++)
{
dp[i+1][j]=min(dp[i+1][j],dp[i][j]+stayright[i]);
dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]-2*t*i+toright[i]);
if (j) dp[i+1][j-1]=min(dp[i+1][j-1],dp[i][j]+2*t*i+toleft[i]);
if (j) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+stayleft[i]);
}
}
ll ans=dp[n][0]+(n+1)*t;
cout <<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... | ||||
