Submission #1061153

# Submission time Handle Problem Language Result Execution time Memory
1061153 2024-08-16T06:44:37 Z 12345678 Reconstruction Project (JOI22_reconstruction) C++17
7 / 100
1452 ms 28496 KB
#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()&&x>=dp[i][idx[i]]) idx[i]++;
        for (int i=1; i<n; i++)
        {
            ll tmp=dp[i][idx[i]]-x;
            if (idx[i]!=0) tmp=min(tmp, x-dp[i][idx[i]-1]);
            res+=tmp;
        }
        cout<<res<<'\n';
    }
}

Compilation message

reconstruction.cpp:6: warning: ignoring '#pragma gcc ' [-Wunknown-pragmas]
    6 | #pragma gcc-optimize("o3, unroll-loops")
      | 
reconstruction.cpp: In function 'int main()':
reconstruction.cpp:25:46: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i=1; i<n; i++) while (idx[i]!=dp[i].size()&&x>=dp[i][idx[i]]) idx[i]++;
      |                                        ~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1432 ms 26156 KB Output is correct
5 Correct 1452 ms 26548 KB Output is correct
6 Correct 1428 ms 26192 KB Output is correct
7 Correct 1187 ms 28244 KB Output is correct
8 Correct 1094 ms 28260 KB Output is correct
9 Correct 1072 ms 28172 KB Output is correct
10 Correct 1424 ms 26452 KB Output is correct
11 Correct 1168 ms 28496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -