Untitled
ducsieumanh1hitlanamguku
plain_text
a month ago
493 B
2
Indexable
Never
#include <bits/stdc++.h> using namespace std; int main() { int n; int mid; int e=0; int sl; int a[100],b[100]; cin>>n>>sl; mid=(n+1)/2; for (int i=1;i<=sl;i++) { cin>>a[i]>>b[i]; } for (int i=1;i<=sl;i++) { if (abs(a[i]-mid)>abs(b[i]-mid)) { e+=abs(a[i]-mid)*10+abs(b[i]-mid)*5; } else if (abs(a[i]-mid)<abs(b[i]-mid)) { e+=abs(a[i]-mid)*5+abs(b[i]-mid)*10; } else if (abs(a[i]-mid)==abs(b[i]-mid)) { e+=abs(a[i]-mid)*15; } } cout<< e; }
Leave a Comment