Submission #475186

#TimeUsernameProblemLanguageResultExecution timeMemory
475186Ahmed57Po (COCI21_po)C++14
70 / 70
13 ms1224 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n;cin>>n;long long arr[n+1]={0}; for(int i=1;i<=n;i++)cin>>arr[i];stack<int>s; s.push(0); long long ans = 0; for(int i=1;i<=n;i++){ while(s.top()>arr[i]){ s.pop();ans++; } if(s.top()<arr[i])s.push(arr[i]); } ans+=s.size()-1; cout<<ans<<"\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:6:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    6 |     for(int i=1;i<=n;i++)cin>>arr[i];stack<int>s;
      |     ^~~
Main.cpp:6:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    6 |     for(int i=1;i<=n;i++)cin>>arr[i];stack<int>s;
      |                                      ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...