Submission #1078854

#TimeUsernameProblemLanguageResultExecution timeMemory
1078854mickey080929Radio Towers (IOI22_towers)C++17
11 / 100
4053 ms1612 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; const int inf = 2e9 + 10; int N; vector<int> H; void init(int _N, vector<int> _H) { N = _N; H = _H; } int max_towers(int L, int R, int D) { vector<int> id; for (int i=L; i<=R; i++) { id.push_back(i); } sort(id.begin(), id.end(), [&] (int &u, int &v) { return H[u] > H[v]; }); int ans = 1; vector<int> pos = {L-1, R+1}; for (int i=0; i<id.size(); i++) { vector<int> cur = pos; cur.push_back(id[i]); sort(cur.begin(), cur.end()); int cnt = 0; for (int j=0; j+1<cur.size(); j++) { int lh, rh; if (cur[j] == L-1) lh = inf; else lh = H[cur[j]]; if (cur[j+1] == R+1) rh = inf; else rh = H[cur[j+1]]; for (int k=cur[j]+1; k<=cur[j+1]-1; k++) { if (H[k] <= min(lh, rh) - D) { cnt ++; break; } } } if (ans <= cnt) { ans = cnt; pos = cur; } } return ans; }

Compilation message (stderr)

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i=0; i<id.size(); i++) {
      |                   ~^~~~~~~~~~
towers.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j=0; j+1<cur.size(); j++) {
      |                       ~~~^~~~~~~~~~~
#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...