Submission #586304

# Submission time Handle Problem Language Result Execution time Memory
586304 2022-06-30T06:30:35 Z M_W Safety (NOI18_safety) C++17
0 / 100
23 ms 5608 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 5608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -