Skip to content

Instantly share code, notes, and snippets.

@Hacv16
Created October 7, 2024 00:01
Show Gist options
  • Save Hacv16/82ce4c039f8ba33669ef8d51ca7debfb to your computer and use it in GitHub Desktop.
Save Hacv16/82ce4c039f8ba33669ef8d51ca7debfb to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
int resp = 0;
for(int i = 1; i <= n; i++)
{
int c, s; cin >> c >> s;
int horario = (c > s ? c - s : s - c);
int antihorario = (c > s ? 10 + s - c : 10 + c - s);
resp += min(horario, antihorario);
}
cout << resp << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment