이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector<ll>;
int main()
{
int N;
cin >> N;
vll A(1+N), B(1+N);
ll totA = 0, totB = 0;
for(int i = 1; i <= N; i++)
{
cin >> A[i] >> B[i];
totA += A[i];
totB += B[i];
}
A[0] = B[0] = 0;
ll res = 0;
ll currA = 0, currB = 0;
for(int b = 1; b < N; b++)
{
currA += A[b];
currB += B[b];
if(currA < currB) res += currB - currA;
if((totA - currA) < (totB - currB)) res += (totB - currB) - (totA - currA);
}
cout << res << '\n';
}
# | 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... |