Submission #403678

# Submission time Handle Problem Language Result Execution time Memory
403678 2021-05-13T11:10:21 Z CursedCode Fireworks (APIO16_fireworks) C++14
0 / 100
2 ms 1856 KB
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int N,M,i,j;
	long long a[100000],b[100000],x = 1000000000,y = 0,ans = 0,ansl = 1000000000;
	cin >> N >> M;
	for(i = 1;i <= N + M - 1;i++){
		cin >> a[i] >> b[i];
	}
	sort(b + 1,b + M);
	if(M%2 == 1){
		for(i = 1;i <= N + M - 1;i++){
			ans += abs(b[(M + 1)/2] - b[i]);
		}
		cout << ans;
	}
	else{
		long long x = (b[M / 2] + b[M / 2 + 1])/2;
		for(i = 1;i <= N + M - 1;i++){
			ans += abs(x - b[i]);
		}
		cout << ans;
	}
	return 0;
}

Compilation message

fireworks.cpp: In function 'int main()':
fireworks.cpp:8:12: warning: unused variable 'j' [-Wunused-variable]
    8 |  int N,M,i,j;
      |            ^
fireworks.cpp:9:32: warning: unused variable 'x' [-Wunused-variable]
    9 |  long long a[100000],b[100000],x = 1000000000,y = 0,ans = 0,ansl = 1000000000;
      |                                ^
fireworks.cpp:9:47: warning: unused variable 'y' [-Wunused-variable]
    9 |  long long a[100000],b[100000],x = 1000000000,y = 0,ans = 0,ansl = 1000000000;
      |                                               ^
fireworks.cpp:9:61: warning: unused variable 'ansl' [-Wunused-variable]
    9 |  long long a[100000],b[100000],x = 1000000000,y = 0,ans = 0,ansl = 1000000000;
      |                                                             ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 2 ms 1740 KB Output is correct
3 Incorrect 2 ms 1740 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 2 ms 1740 KB Output is correct
3 Incorrect 2 ms 1740 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Correct 2 ms 1740 KB Output is correct
3 Incorrect 2 ms 1740 KB Output isn't correct
4 Halted 0 ms 0 KB -