Submission #833546

# Submission time Handle Problem Language Result Execution time Memory
833546 2023-08-22T06:46:10 Z Trumling Catfish Farm (IOI22_fish) C++17
6 / 100
124 ms 15672 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define pb push_back
#define INF 9999999999999999

long long max_weights(int N, int M, vector<int> X, vector<int> Y,vector<int> W) 
{
  ll sum1=0,sum2=0;
  vector<pair<ll,ll>>z,o;

  for(int i=0;i<M;i++)
  {
    if(X[i])
    {
      sum1+=W[i];
      o.pb({Y[i],W[i]});
    }
    else
    {
      sum2+=W[i];
      z.pb({Y[i],W[i]});
    }

  }
  sort(all(z));
  sort(all(o));

  if(N==2)
  return max(sum1,sum2);

  ll maxi=max(sum1,sum2);

  ll idx=0,l=0,r=0;
  for(int i=0;i<z.size();i++)
  {
    l+=z[i].S;
    while(idx!=o.size() && o[idx].F<=z[i].F)
    {
      r+=o[idx].S;
      idx++;
    }

    maxi=max(maxi,l+sum1-r);
  }

  return maxi;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i=0;i<z.size();i++)
      |               ~^~~~~~~~~
fish.cpp:43:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     while(idx!=o.size() && o[idx].F<=z[i].F)
      |           ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4308 KB Output is correct
2 Correct 32 ms 4808 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 124 ms 15564 KB Output is correct
6 Incorrect 108 ms 15672 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 72 ms 7248 KB Output is correct
3 Correct 66 ms 8396 KB Output is correct
4 Correct 27 ms 4416 KB Output is correct
5 Correct 33 ms 4908 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 260 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 25 ms 4544 KB Output is correct
13 Correct 31 ms 4940 KB Output is correct
14 Correct 30 ms 3948 KB Output is correct
15 Correct 32 ms 4288 KB Output is correct
16 Correct 27 ms 4040 KB Output is correct
17 Correct 28 ms 4308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 17 ms 2636 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310323004046'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 17 ms 2636 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4308 KB Output is correct
2 Correct 32 ms 4808 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 124 ms 15564 KB Output is correct
6 Incorrect 108 ms 15672 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -