# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136926 | 2019-07-26T14:45:39 Z | dnass | Unija (COCI17_unija) | C++14 | 460 ms | 31032 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int lld; lld n; pair<lld, lld> rectangles[1000100]; bool comp(pair<lld, lld> lhs, pair<lld, lld> rhs){ if(rhs.second==lhs.second) return lhs.first<rhs.first; return lhs.second>rhs.second; } int main(){ scanf("%lld", &n); for(lld i=0;i<n;i++){ scanf("%lld %lld", &rectangles[i].first, &rectangles[i].second); rectangles[i].first/=2; rectangles[i].second/=2; } sort(rectangles, rectangles+n, comp); lld area = 0; lld mx_height = 0; lld nexty; for(lld i=1;i<=n;i++){ if(i==n||rectangles[i].second!=rectangles[i-1].second){ if(i==n) nexty = 0; else nexty = rectangles[i].second; mx_height = max(mx_height, rectangles[i-1].first); area += mx_height*(rectangles[i-1].second-nexty); } } printf("%lld\n", 4*area); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 396 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 408 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
3 | Correct | 4 ms | 372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 460 ms | 19780 KB | Output is correct |
2 | Correct | 458 ms | 30948 KB | Output is correct |
3 | Correct | 458 ms | 30996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 368 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 1176 KB | Output is correct |
2 | Correct | 14 ms | 1116 KB | Output is correct |
3 | Correct | 14 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 3176 KB | Output is correct |
2 | Correct | 42 ms | 3156 KB | Output is correct |
3 | Correct | 43 ms | 3256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 8008 KB | Output is correct |
2 | Correct | 133 ms | 9104 KB | Output is correct |
3 | Correct | 130 ms | 9076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 450 ms | 20248 KB | Output is correct |
2 | Correct | 455 ms | 30888 KB | Output is correct |
3 | Correct | 456 ms | 31032 KB | Output is correct |