- Published on
@codersaky77 posted "FARMER JOHN'S FAV PERATION"
- Authors

- Name
- aimode.news
- @aimode_news
I came astross this question from USACO SILVER 2025, being new on to take mehour to crack it, and when I did, it used a basic policy that SUM (a [i]-x) is mine if x is median.
CODE->
#Include
#definine fastio() ios:: sync with stdio (false); cin.tie (NULL); cout.tie (NULL)
# Definine in long long #
# Definine double long double
typedef long long longll;
typedef unsigned long long long ll;
typedef vector
typedef vector
I don't know.
I don't know.
#definine pb push back
# Definine ff first
#Definine ss second
#define all(x).begin(),(x).end()
#definine rall(x)(x).rbegin(),(x).rend()
# Define Yes round #
# Definine no cut #
# Definine endl 'n'
#definine IN VEC(v,n)vector
#define IN ARR(arr, n) for (int i=0;i)
= 1e18;
Const int MOD = 1e9 + 7;
void Solve() {
Inn n,m;
I don't know.
vector
For(int i=0;i)
a[i]=y%m;
♪ I'm sorry ♪
sort (all(a));
For(int i=0;i)
Int me=i+n/2;
Int t1=(me-i)*a [me];
Inttt2=(pref[me]-pref[i];
Int t3=(pref[n+i]-pref[me];
Int t4=(n+i-me)*a [me];
ns=min (ans, t1+t3-t2-t4);
♪ I'm sorry ♪
Don't worry.
While(t-)
Solve();
♪ I'm sorry ♪
Return 0;
♪ I'm sorry ♪