Submission #453446

#TimeUsernameProblemLanguageResultExecution timeMemory
453446marcipan5000Sure Bet (CEOI17_sure)C++14
100 / 100
146 ms5448 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ll; int n; long double x; vector<ll> a,b; bool kis(ll a,ll b) { return(a>b); } int main() { ios_base::sync_with_stdio(false); cin >> n; a.push_back(0); b.push_back(0); for (int i=0;i<n;i++) { cin >> x; a.push_back(x); cin >> x; b.push_back(x); } sort(++a.begin(),a.end(),kis); sort(++b.begin(),b.end(),kis); for (int i=1;i<a.size();i++) { a[i]+=a[i-1]; b[i]+=b[i-1]; } ll ans=0; int l=0; for (int i=0;i<a.size();i++) { while ((l<b.size())&&(b[l]<a[i])) { ans=max(ans,min(a[i],b[l])-(long double)(i+l)); l++; } if (l<b.size()) { ans=max(ans,min(a[i],b[l])-(long double)(i+l)); } } printf("%.4lf",(double)ans); /* for (int i=0;i<a.size();i++) { cout << a[i] << " "; } cout << endl; for (int i=0;i<a.size();i++) { cout << b[i] << " "; } cout << endl; */ return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i=1;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while ((l<b.size())&&(b[l]<a[i])) {
      |                 ~^~~~~~~~~
sure.cpp:41:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (l<b.size()) {
      |             ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...