Submission #239101

# Submission time Handle Problem Language Result Execution time Memory
239101 2020-06-14T11:44:10 Z urd05 Travelling Merchant (APIO17_merchant) C++14
0 / 100
28 ms 1152 KB
#include <bits/stdc++.h>
using namespace std;

int buy[100][1000];
int sell[100][1000];
typedef pair<int,int> P;
vector<P> adj[100];
long long dist[100];
const long long INF=1e15;

int main(void) {
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=0;i<n;i++) {
        dist[i]=INF;
        for(int j=0;j<k;j++) {
            scanf("%d %d",&buy[i][j],&sell[i][j]);
        }
    }
    for(int i=0;i<m;i++) {
        int u,v,w;
        scanf("%d %d %d",&u,&v,&w);
        u--;
        v--;
        adj[u].push_back(P(v,w));
    }
    long long prof=0;
    for(int i=0;i<k;i++) {
        prof=max(prof,(long long)sell[0][i]-buy[0][i]);
    }
    for(int i=0;i<adj[0].size();i++) {
        int nt=adj[0][i].first;
        dist[nt]=adj[0][i].second;
    }
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            for(int k=0;k<adj[j].size();k++) {
                int nt=adj[j][k].first;
                dist[nt]=min(dist[nt],dist[j]+adj[j][k].second);
            }
        }
    }
    printf("%lld",prof/dist[0]);
}

Compilation message

merchant.cpp: In function 'int main()':
merchant.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<adj[0].size();i++) {
                 ~^~~~~~~~~~~~~~
merchant.cpp:37:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int k=0;k<adj[j].size();k++) {
                         ~^~~~~~~~~~~~~~
merchant.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
merchant.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d",&buy[i][j],&sell[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&u,&v,&w);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -