# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000564 | De3b0o | Reconstruction Project (JOI22_reconstruction) | C++14 | 2074 ms | 49624 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>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
using namespace std;
ll n , m , q;
pll a[1000009];
ll fans[1000009];
vector<ll> ed[509];
ll idx[509];
ll ls[509];
int main()
{
d3
cin >> n >> m;
for(int i = 0 ; m>i ; i++)
{
ll u , v , w;
cin >> u >> v >> w;
ed[u].pb(w);
}
for(int i = 1 ; n>=i ; i++)
{
ls[i]=1e18;
sort(ed[i].begin(),ed[i].end());
ed[i].pb(1e18);
}
cin >> q;
for(int i = 0 ; q>i ; i++)
{
ll x;
cin >> x;
a[i].F=x;
a[i].S=i;
}
sort(a,a+q);
ll px = -1;
for(int i = 0 ; q>i ; i++)
{
ll x = a[i].F;
ll ans = 0;
for(int j = 1 ; n>j ; j++)
{
int h = idx[j];
ls[j]+=x-px;
for(; ed[j].size()>h ; h++)
{
if(abs(ed[j][h]-x)>ls[j])
break;
ls[j]=abs(ed[j][h]-x);
}
h--;
idx[j]=h;
ans+=ls[j];
}
fans[a[i].S]=ans;
px=x;
}
for(int i = 0 ; q>i ; i++)
cout << fans[i] << "\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... |