CSES - Datatähti 2017 alku - Results
Submission details
Task:Kolikot
Sender:Senpai
Submission time:2016-10-04 00:52:32 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:19: error: no matching function for call to 'min(int, long long int&)'
         if(min(1,c)==1 && c!=1){
                   ^
input/code.cpp:24:19: note: candidates are:
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/sstream:38,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from input/code.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: note:   template argument deduction/substitution failed:
input/code.cpp:24:19: note:   deduced co...

Code

#include <bits/stdc++.h>
using namespace std;

long long a,b,c,x;
int main(){
    cin>>a;
    vector<long long> v(a); 
    vector<long long> s(a);
      for(int i=0; i<a; i++){
          cin>>x;
          v[i]=x;
          
          }
    
    sort(v.begin(),v.end());
     
     for(int i=0; i<a; i++){
          b+=v[i];
         s[i]=b;
          }
   long long i=0;
    c=v[0];
    while(i-1<=a){
        if(min(1,c)==1 && c!=1){
            cout<<1;
            break;}
        
        if(v[i+1]>s[i]+1){ 
            cout<<s[i]+1;
            break;}
            
        else i++;
            
    }
    }