Submission #1153961

#TimeUsernameProblemLanguageResultExecution timeMemory
1153961salmonPo (COCI21_po)C++20
20 / 70
8 ms1092 KiB
#include <bits/stdc++.h> using namespace std; int N; int lst[100100]; vector<int> b; int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ scanf(" %d",&lst[i]); } int cont = 0; for(int i = 0; i < N; i++){ while(!b.empty() && b.back() > lst[i]){ b.pop_back(); cont++; } if(b.empty() || b.back() != lst[i]) b.push_back(lst[i]); } cont += b.size(); printf("%d\n",cont); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
Main.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf(" %d",&lst[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...