Submission #1112405

#TimeUsernameProblemLanguageResultExecution timeMemory
1112405vjudge1Baloni (COCI15_baloni)C++17
0 / 100
2069 ms3664 KiB
#include <bits/stdc++.h> using namespace std; int main() { int s = 0, a; cin >> a; vector<int> d(a); for (int i = 0; i < a; i++) { cin >> d[i]; } while (true) { int maxi = -1, max = INT_MIN; for (int i = 0; i < d.size(); i++) { if (d[i] > max) { max = d[i]; maxi = i; } } if (maxi == -1) { break; } int ua = -1; for (int i = maxi; i < d.size() - 1; i++) { if (d[i] - 1 == d[i + 1]) { d.erase(d.begin() + i); ua = i; i--; } else { break; } } if (ua != -1 && ua < d.size()) { d.erase(d.begin() + ua); } s++; } cout << s; return 0; }

Compilation message (stderr)

baloni.cpp: In function 'int main()':
baloni.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int i = 0; i < d.size(); i++) {
      |                         ~~^~~~~~~~~~
baloni.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int i = maxi; i < d.size() - 1; i++) {
      |                            ~~^~~~~~~~~~~~~~
baloni.cpp:40:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if (ua != -1 && ua < d.size()) {
      |                         ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...