Submission #1061151

#TimeUsernameProblemLanguageResultExecution timeMemory
106115112345678Reconstruction Project (JOI22_reconstruction)C++17
0 / 100
1 ms2396 KiB
#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)

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()-1&&x>=dp[i][idx[i]+1]) idx[i]++;
      |                                        ~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...