Precreation contest files

This commit is contained in:
2026-02-11 11:28:23 +07:00
parent 0a8ea477bb
commit cb9f7cab30
134 changed files with 1848 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,8 @@
7
1 4 1 2
1 5 2 1
3 2 2 1
1 3 2 1
2 1 1 2
3 1 1 2
1 100 10000000 10000000

View File

@@ -0,0 +1,7 @@
3
6
1
3
-1
-1
990000000

View File

@@ -0,0 +1,43 @@
#include <iostream>
using namespace std;
void solve() {
int a, b, x, y;
cin >> a >> b >> x >> y;
if (a > b) {
if (a - b == 1) {
if (a % 2 != 0) {
cout << y << endl;
return;
}
}
cout << "-1\n";
return;
}
int diff = b - a;
int xdiff = diff * x;
if (diff % 2 == 0) {
cout << min(xdiff, ((diff * x) / 2) + ((diff * y) / 2)) << endl;
return;
} else {
if (a % 2 != 0) {
cout << min(xdiff, (diff / 2 + 1) * x + (diff / 2) * y) << endl;
return;
} else {
cout << min(xdiff, (diff / 2) * x + (diff / 2 + 1) * y) << endl;
return;
}
}
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}