This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC target("popcnt")
using namespace std;
#define ll long long
#define vt vector
#define pb push_back
#define fi first
#define se second
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
typedef unsigned long long ull;
#include<fstream>
ifstream fin("cowpatibility.in");
ofstream fout("cowpatibility.out");
#define pii pair<int, int>
#define pll pair<ll, ll>
const ll mod = 1e9 + 7, p = 1299709, mod2 = 1e9 + 9;
const int mxn = 1e5;
int k, n;
ll ans = 0;
vt<pll>v;
void solve1(){
vt<ll>points;
for(auto [aa, bb]: v){
points.pb(aa); points.pb(bb);
}
sort(points.begin(), points.end());
ll med = points[points.size() / 2];
for(int i = 0; i < points.size(); i++){
ans += abs(med - points[i]);
}
cout << ans;
}
void solve2(){
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> k >> n;
forr(i, 0, n){
char a, b; int aa, bb;
cin >> a >> aa >> b >> bb;
if(a == b)ans += abs(aa - bb);
else v.pb({aa, bb});
}
if(k == 1)solve1();
else solve2();
return 0;
}
Compilation message (stderr)
bridge.cpp: In function 'void solve1()':
bridge.cpp:26:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
26 | for(auto [aa, bb]: v){
| ^
bridge.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i = 0; i < points.size(); i++){
| ~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |