답안 #912342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912342 2024-01-19T10:10:23 Z Alish Reconstruction Project (JOI22_reconstruction) C++17
0 / 100
5000 ms 17524 KB
#include<bits/stdc++.h>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")

using namespace std;

typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;


#define all(x)              x.begin(), x.end()
#define pb                  push_back
#define F                   first
#define S                   second
#define fast_io             ios::sync_with_stdio(false); cout.tie(0); cin.tie(0);
#define debug(x)            cerr<<#x<<" "<<x<<endl;
#define endl                '\n'


const int N = 523;
const int INF=1e9+23;

vector<int> E[N]; // i-> i+1 : weights
int n, m, q;



int main()
{
    fast_io
    cin>>n>>m;
    for (int i=0; i<m; i++){
        int v, u, w;
        cin>>v>>u>>w;
        E[min(u, v)].pb(w);
        if(abs(v-u)!=1) assert(0);
    }
    for (int i=0; i<=n; i++) sort(all(E[i]));

    cin>>q;

    while(q--){
        ll wi; cin>>wi;
        ll ans=0;
        for (int i=1; i<n; i++){
            int t=lower_bound(all(E[i]), wi)-E[i].begin();
            ll temp=INF;
            if(t<E[i].size()) temp=min(temp, abs(wi-E[i][t]));
            t--;
            if(t>=0) temp=min(temp, abs(wi-E[i][t]));
            ans+=temp;
        }
        cout<<ans<<endl;
    }

}

Compilation message

reconstruction.cpp: In function 'int main()':
reconstruction.cpp:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             if(t<E[i].size()) temp=min(temp, abs(wi-E[i][t]));
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 5019 ms 17524 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -