Submission #1055728

# Submission time Handle Problem Language Result Execution time Memory
1055728 2024-08-13T04:33:29 Z 캐나다 선발고사 레전드(#11109) Treasure Hunt (CCO24_day1problem1) C++17
0 / 25
591 ms 83120 KB
#include <bits/stdc++.h>
using namespace std;

int n,m;
typedef pair<int,int> P;
vector<P> adj[1000005];
int arr[1000005];
bool save[1000005];

int main(void) {
    scanf("%d %d",&n,&m);
    vector<P> v;
    for(int i=1;i<=n;i++) {
        scanf("%d",&arr[i]);
        v.push_back(P(arr[i],i));
    }
    for(int i=0;i<m;i++) {
        int u,v,w;
        scanf("%d %d %d",&u,&v,&w);
        adj[u].push_back(P(v,w));
        adj[v].push_back(P(u,w));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size();i++) {
        int now=v[i].second;
        save[now]=true;
        for(int j=0;j<adj[now].size();j++) {
            int nt=adj[now][j].first;
            if (save[nt]) {
                arr[now]=max(arr[now],arr[nt]-adj[now][j].second);
            }
        }
    }
    for(int i=1;i<=n;i++) {
        printf("%d\n",arr[i]);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size();i++) {
      |                 ~^~~~~~~~~
Main.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j=0;j<adj[now].size();j++) {
      |                     ~^~~~~~~~~~~~~~~~
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d %d %d",&u,&v,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 26716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 591 ms 82992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 544 ms 83120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 26716 KB Output isn't correct
2 Halted 0 ms 0 KB -