Submission #535399

#TimeUsernameProblemLanguageResultExecution timeMemory
535399AsymmetrySure Bet (CEOI17_sure)C++17
100 / 100
64 ms3524 KiB
//Autor: Bartłomiej Czarkowski #include <bits/stdc++.h> using namespace std; #ifdef DEBUG template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} #define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n' #else #define debug(...) {} #endif int n; double odp; double wyn[2]; int main() { scanf("%d", &n); vector<vector<double>> v(2, vector<double>(n)); for (int i = 0; i < n; ++i) { scanf("%lf%lf", &v[0][i], &v[1][i]); } sort(v[0].begin(), v[0].end()); sort(v[1].begin(), v[1].end()); reverse(v[0].begin(), v[0].end()); reverse(v[1].begin(), v[1].end()); int p[2] = {0, 0}; while (true) { if (wyn[0] < wyn[1]) { if (p[0] == n) { break; } wyn[0] += v[0][p[0]++]; odp = max(odp, min(wyn[0], wyn[1]) - p[0] - p[1]); } else { if (p[1] == n) { break; } wyn[1] += v[1][p[1]++]; odp = max(odp, min(wyn[0], wyn[1]) - p[0] - p[1]); } } printf("%.4lf\n", odp); return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%lf%lf", &v[0][i], &v[1][i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...