# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061151 | 12345678 | Reconstruction Project (JOI22_reconstruction) | C++17 | 1 ms | 2396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma gcc-optimize("o3, unroll-loops")
const int nx=5e2+5, mx=1e5+5;
ll n, m, a[mx], b[mx], w[mx], x, q, idx[nx];
vector<ll> dp[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=m; i++) cin>>a[i]>>b[i]>>w[i], dp[a[i]].push_back(w[i]);
for (int i=1; i<n; i++) sort(dp[i].begin(), dp[i].end());
for (int i=1; i<n; i++) dp[i].push_back(1e18);
cin>>q;
while (q--)
{
cin>>x;
ll res=0;
for (int i=1; i<n; i++) while (idx[i]!=dp[i].size()-1&&x>=dp[i][idx[i]+1]) idx[i]++;
for (int i=1; i<n; i++)
{
ll tmp=min(dp[i][idx[i]+1]-x, dp[i][idx[i]]-x);
res+=tmp;
}
cout<<res<<'\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |