# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476573 | idiot123 | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 1092 ms | 27580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main(){
int N; cin>>N;
vector<long long> t(N);
for(int i = 0; i < N; i++){
int a, b; cin>>a>>b;
t[i] = a - b;
}
priority_queue<long long, vector<long long>, greater<long long>> q;
for(int i = 0; i < 2*N; i++)q.push(0);
long long shift = 0;
long long val = 0;
for(int i = 1; i <= N; i++){
//wywalamy pierwszy punkt
q.pop();
//przesuwamy
shift += t[i-1];
//pobieramy pozycje pierwszego punktu
long long x = q.top() + shift;
if(x <= 0){
val += abs(x);
q.push(-shift); q.push(-shift);
}else{
q.push(-shift); q.push(-shift);
}
}
long long x = q.top() + shift;
# | 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... |