| 比赛 |
期末考试1 |
评测结果 |
AWWWWWWWWW |
| 题目名称 |
Constructive |
最终得分 |
10 |
| 用户昵称 |
LikableP |
运行时间 |
0.014 s |
| 代码语言 |
C++ |
内存使用 |
1.40 MiB |
| 提交时间 |
2026-02-08 11:34:43 |
显示代码纯文本
#include <cstdio>
#include <cctype>
typedef long long ll;
namespace IO {
const int BUFSIZE = 1 << 20;
char buf[BUFSIZE], *p1, *p2;
char gc() {
if (p1 == p2) {
p2 = (p1 = buf) + fread(buf, 1, BUFSIZE, stdin);
if (p1 == p2) return EOF;
}
return *p1++;
}
template <typename T> T read() {
T res = 0, f = 1;
char ch = gc();
for (; !isdigit(ch); ch = gc()) if (ch == '-') f = -1;
for (; isdigit(ch); ch = gc()) res = (res << 3) + (res << 1) + (ch ^ 48);
return res * f;
}
template <typename T> void write(T x, char ed = '\n') {
if (x < 0) x = -x, putchar('-');
static int sta[sizeof(T) << 2], top = 0;
do {
sta[++top] = x % 10;
x /= 10;
} while (x);
while (top) {
putchar(sta[top--] ^ 48);
}
putchar(ed);
}
};
#include <vector>
const int MAXN = 5e5 + 10;
struct Vector {
ll x, y, c;
} v[MAXN], target;
int n;
namespace Sub1 {
int Work() {
IO::write(target.x * v[2].c + target.y * v[1].c);
return 0;
}
};
int main() {
#ifdef LOCAL
freopen("!input.in", "r", stdin);
freopen("!output.out", "w", stdout);
#else
freopen("tioj_constructive.in", "r", stdin);
freopen("tioj_constructive.out", "w", stdout);
#endif
n = IO::read<int>(), target.x = IO::read<ll>(), target.y = IO::read<ll>();
for (int i = 1; i <= n; ++i) {
v[i].x = IO::read<ll>(), v[i].y = IO::read<ll>(), v[i].c = IO::read<ll>();
}
if (n == 2 && v[1].x == 0 && v[1].y == 1 && v[2].x == 1 && v[2].y == 0) return Sub1::Work();
IO::write(-1);
return 0;
}