Submission #626337

# Submission time Handle Problem Language Result Execution time Memory
626337 2022-08-11T11:52:17 Z boris_mihov Catfish Farm (IOI22_fish) C++17
3 / 100
93 ms 10864 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];

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

    return ans;
}

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

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

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

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

    return ans;
}

llong solveY1()
{
    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 <= m ; ++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);
    }

    if (isOdd) return solveOdd();
    if (isX01) return solveX12();
    if (isY0) return solveY1();
    return solveNSmall();
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3156 KB Output is correct
2 Correct 27 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 93 ms 10864 KB Output is correct
6 Correct 90 ms 10732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3156 KB Output is correct
2 Correct 27 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 93 ms 10864 KB Output is correct
6 Correct 90 ms 10732 KB Output is correct
7 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
8 Halted 0 ms 0 KB -