Submission #872934

#TimeUsernameProblemLanguageResultExecution timeMemory
872934vjudge1Climbers (RMI18_climbers)C++17
5 / 100
1 ms604 KiB
#include<bits/stdc++.h> using namespace std; // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") #define f first #define s second typedef long long ll; ll a[200100]; void solve(){ ll n; cin>>n; for(ll i=1; i<=n; i++) cin>>a[i]; ll l=1,r=n; vector<ll> ord; while(l<=r){ if(a[l] <= a[r]){ ord.push_back(a[l]); l++; } else{ ord.push_back(a[r]); r--; } } ll ans=0; for(ll i=0; i<ord.size()-1; i++){ ans+=abs(ord[i+1]-ord[i]); } cout<<ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; for(int i = 1; i <= t; i++){ // cout<<"Case "<<i<<":\n"; solve(); cout<<'\n'; } }

Compilation message (stderr)

climbers.cpp: In function 'void solve()':
climbers.cpp:24:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(ll i=0; i<ord.size()-1; i++){
      |                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...