제출 #1112408

#제출 시각아이디문제언어결과실행 시간메모리
1112408vjudge1Baloni (COCI15_baloni)C++17
0 / 100
2072 ms3664 KiB
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; vector<int> d(a); for (int i = 0; i < a; i++) { cin >> d[i]; } int s = 0; while (!d.empty()) { int max_value = *max_element(d.begin(), d.end()); auto it = find(d.begin(), d.end(), max_value); int maxi = distance(d.begin(), it); 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; }

컴파일 시 표준 에러 (stderr) 메시지

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