Submission #124042

#TimeUsernameProblemLanguageResultExecution timeMemory
124042RafikHachanaFireworks (APIO16_fireworks)C++14
7 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<int> v; int cost(int x) { int r = 0; for(auto it:v) r+=abs(it-x); return r; } int bs(int s,int f) { if(s==f) return cost(s); int med = (s+f)/2; int a= cost(med); int b = cost(med+1); if(a<b) return bs(s,med); return bs(med+1,f); } main() { int n,m; cin>>n>>m; v.resize(m); int ma = 0,mi = 1e9; for(int i=0;i<m;i++) { int a; cin>>a>>v[i]; ma = max(ma,v[i]); mi = min(mi,v[i]); } cout<<bs(mi,ma)<<endl; }

Compilation message (stderr)

fireworks.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...