Submission #200703

#TimeUsernameProblemLanguageResultExecution timeMemory
200703BTheroFireworks (APIO16_fireworks)C++17
7 / 100
5 ms376 KiB
// Why am I so dumb? :c // chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pii; //template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MAXN = (int)5e2 + 5; int par[MAXN], arr[MAXN]; int n, m; ll f(int x) { ll ret = 0; for (int i = 1; i <= m; ++i) { ret += abs(x - arr[i]); } return ret; } void solve() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; ++i) { scanf("%d %d", &par[i], &arr[i]); } sort(arr + 1, arr + m + 1); printf("%lld\n", min(f(arr[m / 2]), f(arr[(m + 1) / 2]))); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

fireworks.cpp: In function 'void solve()':
fireworks.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
fireworks.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &par[i], &arr[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...