Submission #626329

# Submission time Handle Problem Language Result Execution time Memory
626329 2022-08-11T11:46:21 Z boris_mihov Catfish Farm (IOI22_fish) C++17
0 / 100
26 ms 6348 KB
#include "fish.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>

typedef long long llong;
const int MAXM = 300000 + 10;
const int MAXN = 3000 + 10;
const int INF  = 1e9;

int n, m;
struct Fish
{
    int x, y, w;
    inline friend bool operator < (const Fish &a, const Fish &b)
    {
        return a.x < b.x || (a.x == b.x && a.y < b.y);
    }

} fish[MAXM];

int table[MAXN][MAXN];

llong solveEven()
{
    llong ans = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        ans += fish[i].w;
    }

    return ans;
}

llong solveX01()
{
    llong sum[2];
    sum[0] = sum[1] = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        sum[fish[i].x] += fish[i].w; 
    }

    std::sort(fish+1, fish+1+n);
    int ptr0 = 1;
    int ptr1 = 1;
    while (ptr1 <= n && fish[ptr1].x == 0) ptr1++;
    if (ptr1 == n+1) return sum[0];

    sum[0] = 0;
    llong ans = sum[1];
    while (fish[ptr0].x == 0)
    {
        sum[0] += fish[ptr0].w;
        while (ptr1 <= n && fish[ptr1].y <= fish[ptr0].y)
        {
            sum[1] -= fish[ptr1].w;
            ++ptr1;
        }

        ans = std::max(sum[0], sum[1]);
    }

    return ans;
}

llong solveY0()
{
    llong ans = 0;
    return ans;
}

llong solveNSmall()
{
    llong ans = 0;
    return ans;
}

llong max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) 
{
    n = N;
    m = M;
    bool isOdd = true;
    bool isX01 = true;
    bool isY0 = true;

    for (int i = 1 ; i <= n ; ++i)    
    {
        ++X[i-1];
        ++Y[i-1];
        fish[i].x = X[i-1];
        fish[i].y = Y[i-1];
        fish[i].w = W[i-1];
        isOdd &= (fish[i].x &1);
        isX01 &= (fish[i].x <= 1);
        isY0 &= (fish[i].y == 0);
    }

    assert(isOdd);
    if (isOdd) return solveEven();
    if (isX01) return solveX01();
    if (isY0) return solveY0();
    return solveNSmall();
}
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 6348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 6348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -