Submission #817039

#TimeUsernameProblemLanguageResultExecution timeMemory
817039finn__Radio Towers (IOI22_towers)C++17
4 / 100
693 ms1452 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; constexpr size_t N = 100000; int subtask, h[N]; size_t peak_pos; void init(int n, vector<int> h_) { copy(h_.begin(), h_.end(), h); bool increasing = 1; subtask = 1; for (size_t i = 0; i + 1 < n; ++i) { if (h[i] < h[i + 1] && !increasing) { subtask = 2; break; } if (h[i] > h[i + 1]) increasing = 0; } if (subtask == 1) { while (peak_pos + 1 < n && h[peak_pos + 1] > h[peak_pos]) ++peak_pos; return; } } int max_towers(int l, int r, int d) { if (subtask == 1) { if (l >= peak_pos || r <= peak_pos) return 1; return (h[peak_pos] >= h[l] + d && h[peak_pos] >= h[r] + d) + 1; } }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:15:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     for (size_t i = 0; i + 1 < n; ++i)
      |                        ~~~~~~^~~
towers.cpp:28:29: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         while (peak_pos + 1 < n && h[peak_pos + 1] > h[peak_pos])
      |                ~~~~~~~~~~~~~^~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (l >= peak_pos || r <= peak_pos)
      |             ~~^~~~~~~~~~~
towers.cpp:38:32: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (l >= peak_pos || r <= peak_pos)
      |                              ~~^~~~~~~~~~~
towers.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...