Submission #916264

# Submission time Handle Problem Language Result Execution time Memory
916264 2024-01-25T14:52:58 Z hariaakas646 Fireworks (APIO16_fireworks) C++14
7 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, l, r) for(int i=l; i<r; i++)
#define frange(i, l) forr(i, 0, l)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef long long lli;
typedef vector<vi> vvi;
typedef vector<lli> vll;
typedef vector<bool> vb;
typedef set<int> seti;
typedef multiset<int> mseti;

void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
}

int n, m;

vector<vector<pair<int, lli>>> graph;
// vll dp;

vector<lli> dfs(int x) {
    if(x > n) {
        vector<lli> vec(301, 1e16);
        vec[0] = 0;
        return vec;
    }
    lli tot = 0;
    vll vec(301, 0);
    for(auto e : graph[x]) {
        auto v = dfs(e.f);
        forr(i, 0, 301) {
            lli mi = 1e16;
            forr(j, 0, i+1) {
                mi = min(mi, abs(j+e.s-i) + v[j]);
            }
            vec[i] += mi;
        }
    }
    return vec;
}

int main() {
    // usaco();
    
    scd(n);
    scd(m);

    // graph = vector<vector<pair<int, lli>>>(n+1);

    vll vec;

    forr(i, 1, m+1) {
        int pa;
        lli c;
        scd(pa);
        sclld(c);
        vec.pb(c);
    }
    sort(all(vec));
    // vll out = dfs(1);

    // lli mi = 1e16;
    // forr(i, 0, 301) mi = min(mi, out[i]);

    // printf("%lld", *min_element(all(dfs(1))));
    lli mi = 0;
    lli v = vec[m/2];

    for(auto e : vec) mi += abs(e-v);
    printf("%lld", mi);
}

Compilation message

fireworks.cpp: In function 'std::vector<long long int> dfs(int)':
fireworks.cpp:41:9: warning: unused variable 'tot' [-Wunused-variable]
   41 |     lli tot = 0;
      |         ^~~
fireworks.cpp: In function 'void usaco()':
fireworks.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fireworks.cpp: In function 'int main()':
fireworks.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
fireworks.cpp:59:5: note: in expansion of macro 'scd'
   59 |     scd(n);
      |     ^~~
fireworks.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
fireworks.cpp:60:5: note: in expansion of macro 'scd'
   60 |     scd(m);
      |     ^~~
fireworks.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
fireworks.cpp:69:9: note: in expansion of macro 'scd'
   69 |         scd(pa);
      |         ^~~
fireworks.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
fireworks.cpp:70:9: note: in expansion of macro 'sclld'
   70 |         sclld(c);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -