- 海底高铁
海底高铁70WA 求调
- 2025-4-21 13:22:26 @
海底高铁70WA 求调
跟着猴哥の题解写的,只有70分
求调
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long n, m, p[N], a[N], b[N], c[N], d[N], ans;
int main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
cin >> p[i];
for (int i = 1; i <= n - 1; i++)
cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= m - 1; i++)
{
int l = min(p[i], p[i + 1]), r = max(p[i], p[i + 1]);
d[l]++, d[r]--;
}
for (int i = 1; i <= n - 1; i++)
d[i] += d[i - 1];
for (int i = 1; i <= n - 1; i++)
{
int noBuy = d[i] * a[i], buy = d[i] * b[i] + c[i];
ans += min(noBuy, buy);
}
cout << ans;
return 0;
}
2 comments
-
C24tanhaolun LV 6 @ 2025-4-22 13:47:57
-
2025-4-21 13:25:16@
测试样例也是对的
- 1
Information
- ID
- 1011
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 64
- Accepted
- 17
- Uploaded By