# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223563 | 2020-04-15T12:47:53 Z | Ruxandra985 | Art Exhibition (JOI18_art) | C++14 | 5 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; pair <long long , long long> v[500010]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i; long long curr , sol; fscanf (fin,"%d",&n); for (i = 1 ; i <= n ; i++){ fscanf (fin,"%lld%lld",&v[i].first,&v[i].second); } sort (v + 1 , v + n + 1); curr = sol = 0; for (i = 1 ; i <= n ; i++){ if (curr + v[i].first - v[i + 1].first >= v[i].first - v[i + 1].first){ curr += v[i].first - v[i + 1].first + v[i].second; if (i + 1 <= n) sol = max(sol , curr + v[i + 1].second); } else curr = v[i].first - v[i + 1].first + v[i].second; sol = max(sol , v[i].second); } fprintf (fout,"%lld",sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 4 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |