28052023-01-26 10:16:48gkataFasor (40)cpp17Forditási hiba
#include <iostream>
//#include <fstream>
#include <vector>
#include <climits>
#define ll long long

using namespace std;

//ifstream cin("fasor.in");
//ofstream cout("fasor.out");

vector <ll>x;

ll n,k,i,j,a,maxi=LONG_MIN,maxi2=LONG_MIN,pos,pos2;

int main()
{
    cin>>n>>k;
    for(i=1;i<=n;++i)
    {
        cin>>a;
        x.push_back(a);
    }

    for(i=0;i<=k;++i)
        if(x[i]>maxi)
        {
            maxi=x[i];
            pos=i;
        }
    if(maxi==x.end()) cout<<pos+1;
    else
    {
        if((pos+k)<n)
    {
        for(i=(pos+1);i<=(pos+k);++i)
        if(x[i]>maxi2)
        {
            maxi2=x[i];
            pos2=i;
        }
    }
    else
    {
        for(i=(pos+1);i<n;++i)
        if(x[i]>maxi2)
        {
            maxi2=x[i];
            pos2=i;
        }
    }
    if(maxi>=maxi2) cout<<pos+1;
        else
        {
            while(maxi<maxi2)
            {
                pos=pos2;
                maxi=maxi2;
                if((pos+k)<n)
                {
                    for(i=(pos+1);i<=(pos+k);++i)
                    if(x[i]>maxi2)
                    {
                        maxi2=x[i];
                        pos2=i;
                    }
                }
                else
                {
                    for(i=(pos+1);i<n;++i)
                    if(x[i]>maxi2)
                    {
                        maxi2=x[i];
                        pos2=i;
                    }
                }

            }
            cout<<pos+1;
        }
    }
    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:31:12: error: no match for 'operator==' (operand types are 'long long int' and 'std::vector<long long int>::iterator')
   31 |     if(maxi==x.end()) cout<<pos+1;
      |        ~~~~^~~~~~~~~
      |        |          |
      |        |          std::vector<long long int>::iterator
      |        long long int
In file included from /usr/include/c++/11/iosfwd:40,
                 from /usr/include/c++/11/ios:38,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from main.cpp:1:
/usr/include/c++/11/bits/postypes.h:222:5: note: candidate: 'template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)'
  222 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/11/bits/postypes.h:222:5: note:   template argument deduction/substitution failed:
main.cpp:31:20: note:   mismatched types 'const std::fpos<_S...