| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363676 | vjudge1 | Potatoes and fertilizers (LMIO19_bulves) | C++20 | 185 ms | 8560 KiB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,d[500005];
signed main(){
priority_queue<int>q;
cin>>n;
int ans=0;
for(int i=1,a,b;i<=n;i++){
cin>>a>>b;
d[i]=d[i-1]+a-b;
}
for(int i=1;i<n;i++){
if(d[i]<0)ans-=d[i],d[i]=0;
if(d[i]>d[n])ans+=(d[i]-d[n]),d[i]=d[n];
}
q.push(0);
for(int i=1;i<=n;i++){
q.push(d[i]);
q.push(d[i]);
int mx=q.top();
q.pop();
ans+=mx-d[i];
}
cout<<ans;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
