답안 #833533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833533 2023-08-22T06:37:15 Z Trumling 메기 농장 (IOI22_fish) C++17
0 / 100
85 ms 11480 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<int,int>>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<int, 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<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     while(idx!=o.size() && o[idx].F<z[i].F)
      |           ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 3300 KB Output is correct
2 Correct 25 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 85 ms 11480 KB Output is correct
6 Incorrect 78 ms 11476 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 44 ms 5700 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40621475040444'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 15 ms 2128 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 15 ms 2128 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722445760742'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 3300 KB Output is correct
2 Correct 25 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 85 ms 11480 KB Output is correct
6 Incorrect 78 ms 11476 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -