Submission #864112

# Submission time Handle Problem Language Result Execution time Memory
864112 2023-10-22T04:08:09 Z Ice_man Truck Driver (IOI23_deliveries) C++17
29 / 100
5500 ms 20240 KB
#include "deliveries.h"
#include <iostream>
#include <vector>


#define maxn 100005
#define maxq 300005
#define INF 1000000010
#define endl '\n'

using namespace std;

long long n;

long long t[maxn];
long long c[maxn];

vector <pair <int , int> > v[maxn];
long long ans;

long long pom;

void dfs(long long node , long long parent)
{
    c[node] = t[node];

    for(long long i = 0; i < (long long)v[node].size(); i++)
    {
        if(v[node][i].first == parent) continue;
        dfs(v[node][i].first , node);

        ans += v[node][i].second * min(c[v[node][i].first] , pom - c[v[node][i].first]) * 2;
        c[node] += c[v[node][i].first];
    }

}

void init(int N, vector<int> U, vector<int> V, vector<int> W, vector<int> T)
{
    pom = 1;
    n = N;
    ///cout << pom << endl;
    for(long long i = 0; i < (long long)U.size(); i++) v[U[i]].push_back({V[i] , W[i]});
    for(long long i = 0; i < (long long)V.size(); i++) v[V[i]].push_back({U[i] , W[i]});



    for(long long i = 0; i < T.size(); i++) pom += T[i];

    ///cout << pom << endl;

    for(long long i = 0; i < T.size(); i++) t[i] = T[i];
}



long long max_time(int S , int X)
{
    pom -= t[S];
    pom += X;
    t[S] = X;

    ans = 0;

    dfs(0 , -1);
    return ans;

}

/**int main()
{
    init(5, {0, 0, 1, 1}, {1, 2, 3, 4}, {1, 2, 3, 1}, {0, 0, 1, 0, 1});
    cout << max_time(0 , 1) << endl;


    return 0;
}*/

Compilation message

deliveries.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
deliveries.cpp:48:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(long long i = 0; i < T.size(); i++) pom += T[i];
      |                          ~~^~~~~~~~~~
deliveries.cpp:52:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(long long i = 0; i < T.size(); i++) t[i] = T[i];
      |                          ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 70 ms 10064 KB Output is correct
2 Correct 73 ms 10052 KB Output is correct
3 Correct 73 ms 10068 KB Output is correct
4 Correct 71 ms 10068 KB Output is correct
5 Correct 75 ms 10576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 6 ms 2652 KB Output is correct
3 Correct 8 ms 2652 KB Output is correct
4 Correct 10 ms 2908 KB Output is correct
5 Correct 10 ms 2916 KB Output is correct
6 Correct 10 ms 2904 KB Output is correct
7 Correct 10 ms 2904 KB Output is correct
8 Correct 10 ms 2904 KB Output is correct
9 Correct 11 ms 2936 KB Output is correct
10 Correct 12 ms 2908 KB Output is correct
11 Correct 8 ms 2648 KB Output is correct
12 Correct 10 ms 2648 KB Output is correct
13 Correct 10 ms 2652 KB Output is correct
14 Correct 13 ms 2916 KB Output is correct
15 Correct 12 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 10064 KB Output is correct
2 Correct 73 ms 10052 KB Output is correct
3 Correct 73 ms 10068 KB Output is correct
4 Correct 71 ms 10068 KB Output is correct
5 Correct 75 ms 10576 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 23 ms 2908 KB Output is correct
8 Correct 2274 ms 4384 KB Output is correct
9 Execution timed out 5546 ms 14720 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 10064 KB Output is correct
2 Correct 73 ms 10052 KB Output is correct
3 Correct 73 ms 10068 KB Output is correct
4 Correct 71 ms 10068 KB Output is correct
5 Correct 75 ms 10576 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 33 ms 3000 KB Output is correct
8 Correct 3172 ms 4920 KB Output is correct
9 Execution timed out 5524 ms 20240 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 10064 KB Output is correct
2 Correct 73 ms 10052 KB Output is correct
3 Correct 73 ms 10068 KB Output is correct
4 Correct 71 ms 10068 KB Output is correct
5 Correct 75 ms 10576 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 6 ms 2652 KB Output is correct
8 Correct 8 ms 2652 KB Output is correct
9 Correct 10 ms 2908 KB Output is correct
10 Correct 10 ms 2916 KB Output is correct
11 Correct 10 ms 2904 KB Output is correct
12 Correct 10 ms 2904 KB Output is correct
13 Correct 10 ms 2904 KB Output is correct
14 Correct 11 ms 2936 KB Output is correct
15 Correct 12 ms 2908 KB Output is correct
16 Correct 8 ms 2648 KB Output is correct
17 Correct 10 ms 2648 KB Output is correct
18 Correct 10 ms 2652 KB Output is correct
19 Correct 13 ms 2916 KB Output is correct
20 Correct 12 ms 2908 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 23 ms 2908 KB Output is correct
23 Correct 2274 ms 4384 KB Output is correct
24 Execution timed out 5546 ms 14720 KB Time limit exceeded
25 Halted 0 ms 0 KB -