Submission #586304

#TimeUsernameProblemLanguageResultExecution timeMemory
586304M_WSafety (NOI18_safety)C++17
0 / 100
23 ms5608 KiB
#include <bits/stdc++.h> using namespace std; priority_queue<long long> lo; priority_queue<long long, vector<long long>, greater<long long>> hi; int main(){ int N; long long H, x, ymin = 0, shift = 0; scanf("%d %lld %lld", &N, &H, &x); lo.push(x); hi.push(x); for(int i = 1; i < N; i++){ scanf("%lld", &x); shift += H; long long left = lo.top() - shift, right = hi.top() + shift; if(x < left){ lo.push(x + shift); lo.push(x + shift); hi.push(left - shift); ymin += left - x; } else if(x > right){ hi.push(x - shift); hi.push(x - shift); lo.push(right + shift); ymin += x - right; } else{ lo.push(x + shift); hi.push(x - shift); } } printf("%lld", ymin); }

Compilation message (stderr)

safety.cpp: In function 'int main()':
safety.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d %lld %lld", &N, &H, &x);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
safety.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%lld", &x);
      |   ~~~~~^~~~~~~~~~~~
#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...