Submission #833534

# Submission time Handle Problem Language Result Execution time Memory
833534 2023-08-22T06:38:10 Z Trumling Catfish Farm (IOI22_fish) C++17
0 / 100
79 ms 15680 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({i,W[i]});
    }
    else
    {
      sum2+=W[i];
      z.pb({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 23 ms 4296 KB Output is correct
2 Correct 25 ms 4808 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 75 ms 15568 KB Output is correct
6 Incorrect 79 ms 15680 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 0 ms 212 KB Output is correct
2 Incorrect 41 ms 7252 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40621475040444'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 14 ms 2728 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 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
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: '2'
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: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 14 ms 2728 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 23 ms 4296 KB Output is correct
2 Correct 25 ms 4808 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 75 ms 15568 KB Output is correct
6 Incorrect 79 ms 15680 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -