Submission #720539

# Submission time Handle Problem Language Result Execution time Memory
720539 2023-04-08T12:28:32 Z lam Catfish Farm (IOI22_fish) C++17
0 / 100
89 ms 14316 KB
#include "fish.h"

#include <vector>
#define ll long long
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 3e5 + 10;
int n,m;
ii a[maxn]; int w[maxn];
bool cmp(int x, int y)
{
    return a[x]<a[y];
}
ll sub2(vector <int> X, vector <int> Y, vector <int> W)
{
    ll ans=0;
    ll sum=0;
    vector <int> id[2];
    for (int i=0; i<m; i++)
        if (X[i]==0) sum+=W[i], id[0].push_back(i);
    ans=sum;
    sum=0;
    for (int i=0; i<m; i++)
        if (X[i]==1) sum+=W[i], id[1].push_back(i);
    ans=max(ans,sum);
    sort(id[0].begin(),id[0].end(),cmp);
    sort(id[1].begin(),id[1].end(),cmp);
    int it[2];
    it[0]=it[1]=0;
    for (int y=0; y<n; y++)
    {
        while (it[0]<id[0].size()&&a[id[0][it[0]]].ss < y) sum+=w[id[0][it[0]++]];
        while (it[1]<id[1].size()&&a[id[1][it[1]]].ss <= y) sum-=w[id[1][it[1]++]];
        ans=max(ans,sum);
    }
    return ans;
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    n=N; m=M;
    for (int i=0; i<m; i++) a[i]={X[i],Y[i]}, w[i]=W[i];
    return sub2(X,Y,W);
}

Compilation message

fish.cpp: In function 'long long int sub2(std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         while (it[0]<id[0].size()&&a[id[0][it[0]]].ss < y) sum+=w[id[0][it[0]++]];
      |                ~~~~~^~~~~~~~~~~~~
fish.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         while (it[1]<id[1].size()&&a[id[1][it[1]]].ss <= y) sum-=w[id[1][it[1]++]];
      |                ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4668 KB Output is correct
2 Correct 41 ms 5580 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 89 ms 14316 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '0'
6 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: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 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 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 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 33 ms 4668 KB Output is correct
2 Correct 41 ms 5580 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 89 ms 14316 KB 1st lines differ - on the 1st token, expected: '149814460735479', found: '0'
6 Halted 0 ms 0 KB -