Submission #403678

#TimeUsernameProblemLanguageResultExecution timeMemory
403678CursedCodeFireworks (APIO16_fireworks)C++14
0 / 100
2 ms1856 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...