이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll int
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define nl '\n'
#define tb '\t'
#define sp ' '
using namespace std;
const int MX=3005, MOD=998244353, BLOCK=327, INF=1e9+7;
const ll INFF=1e18+7;
const ld ERR=1e-7, pi=3.14159265358979323846;
ll N, A, DP[2][30005];
int main(){
fastio;
cin >> N;
for(ll ii=1, now, bef; ii<=N; ii++){
now=ii%2, bef=now^1;
ll a, b;
cin >> a >> b;
A+=a-b;
for(ll j=0; j<=30000; j++){
DP[now][j]=DP[bef][j]+abs(j-A);
if(j>0)
DP[now][j]=min(DP[now][j], DP[now][j-1]);
}
}
cout << DP[N%2][A] << nl;
}
컴파일 시 표준 에러 (stderr) 메시지
bulves.cpp:19:19: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
19 | const ll INFF=1e18+7;
| ~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |