Submission #793383

#TimeUsernameProblemLanguageResultExecution timeMemory
793383kingfran1907Fireworks (APIO16_fireworks)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;

int n, m;
int parr[maxn], len[maxn];

int main() {
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
		scanf("%d", len+i);
	sort(len, len+m);
	int ac = (m / 2);
	
	llint sol = 0;
	for (int i = 0; i < m; i++) sol += abs(len[ac] - len[i]);
	printf("%lld\n", sol);
	return 0;
}

Compilation message (stderr)

fireworks.cpp: In function 'int main()':
fireworks.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
fireworks.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", len+i);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...