Submission #508663

#TimeUsernameProblemLanguageResultExecution timeMemory
508663CyberSleeperPotatoes and fertilizers (LMIO19_bulves)C++14
24 / 100
153 ms4540 KiB
#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 long long #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, ans; priority_queue<ll> best; int main(){ fastio; cin >> N; for(ll i=1; i<=N; i++){ ll a, b; cin >> a >> b; A+=a-b; ans+=abs(A); if(A<0){ best.push(0); best.push(0); }else{ best.push(A); best.push(A); } best.pop(); } while(best.size()>A) best.pop(); while(best.size()){ ans-=best.top(); best.pop(); } cout << ans << nl; }

Compilation message (stderr)

bulves.cpp: In function 'int main()':
bulves.cpp:42:22: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   42 |     while(best.size()>A)
      |           ~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...