# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
866601 | Rifal | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 75 ms | 23344 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>
#include <fstream>
//#define endl '\n'
#define mod 998244353
#define INF 900000000000000000
//#define cin fin
//#define cout fout
#define fi first
#define se second
using namespace std;
//ofstream fout("intel.out");
//ifstream fin("intel.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
long long n; cin >> n; pair<long long, long long> arr[n]; stack<pair<long long,long long>> stl, str;
long long sum = 0;
for(int i = 0; i < n; i++) {
cin >> arr[i].first >> arr[i].second;
}
for(int i = n-1; i >= 0; i--) {
sum += arr[i].first; sum -= arr[i].second;
if(arr[i].first > 0) str.push({arr[i].first,i});
}
long long ans = 0;
for(long long i = 0; i < n; i++) {
sum += arr[i].second;
sum -= arr[i].first;
if(!str.empty() && str.top().second == i) {
# | 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... |