Submission #979469

#TimeUsernameProblemLanguageResultExecution timeMemory
979469michifiedLightning Conductor (POI11_pio)C++17
45 / 100
632 ms12196 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, i, cur = 0; cin >> n; vector<int> h(n), ans(n); for (i = 0; i < n; i++) cin >> h[i]; vector<int> hull = {0}; for (i = 1; i < n; i++) { if (h[i] > h[hull.back()]) hull.push_back(i); } for (i = 0; i < n; i++) { while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++; ans[i] = max(ans[i], (int) ceil(h[hull[cur]] + sqrt(i - hull[cur]) - 1e-8)); } reverse(h.begin(), h.end()); reverse(ans.begin(), ans.end()); hull = {0}; for (i = 1; i < n; i++) { if (h[i] > h[hull.back()]) hull.push_back(i); } cur = 0; for (i = 0; i < n; i++) { while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++; ans[i] = max(ans[i], (int) ceil(h[hull[cur]] + sqrt(i - hull[cur]) - 1e-8)); } reverse(ans.begin(), ans.end()); reverse(h.begin(), h.end()); for (i = 0; i < n; i++) cout << max(0, ans[i] - h[i]) << endl; return 0; }

Compilation message (stderr)

pio.cpp: In function 'int main()':
pio.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
      |                ~~~~^~~~~~~~~~~~~~~~~
pio.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
      |                ~~~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...