Submission #136926

#TimeUsernameProblemLanguageResultExecution timeMemory
136926dnassUnija (COCI17_unija)C++14
100 / 100
460 ms31032 KiB
#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 (stderr)

unija.cpp: In function 'int main()':
unija.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
unija.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &rectangles[i].first, &rectangles[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#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...