Submission #553783

#TimeUsernameProblemLanguageResultExecution timeMemory
553783hibikiSafety (NOI18_safety)C++11
100 / 100
57 ms5432 KiB
#include<bits/stdc++.h> using namespace std; int main() { int N; long long H,s,shift=0,y_min=0; priority_queue<long long> L,R; scanf("%d %lld",&N,&H); scanf("%lld",&s); L.push(s); R.push(-s); for(int i=2;i<=N;i++) { shift+=H; long long ll = L.top() - shift; long long rr = -R.top() + shift; scanf("%d",&s); if(s<ll) { y_min += ll - s; L.push(s + shift); L.push(s + shift); L.pop(); R.push(-(ll - shift)); } else if(s>rr) { y_min += s - rr; R.push(-(s - shift)); R.push(-(s - shift)); R.pop(); L.push(rr + shift); } else { L.push(s + shift); R.push(-(s - shift)); } } printf("%lld\n",y_min); return 0; }

Compilation message (stderr)

safety.cpp: In function 'int main()':
safety.cpp:18:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   18 |         scanf("%d",&s);
      |                ~^  ~~
      |                 |  |
      |                 |  long long int*
      |                 int*
      |                %lld
safety.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %lld",&N,&H);
      |     ~~~~~^~~~~~~~~~~~~~~~~
safety.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld",&s);
      |     ~~~~~^~~~~~~~~~~
safety.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d",&s);
      |         ~~~~~^~~~~~~~~
#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...