답안 #833535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833535 2023-08-22T06:40:09 Z Trumling 메기 농장 (IOI22_fish) C++17
0 / 100
99 ms 15576 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)
      |           ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 4312 KB Output is correct
2 Correct 31 ms 4804 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 98 ms 15576 KB Output is correct
6 Incorrect 99 ms 15564 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 52 ms 7264 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40604944491929'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 232 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 16 ms 2736 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 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 Correct 0 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 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310936238414'
10 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 Correct 0 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 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310936238414'
10 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 Correct 0 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 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '310936238414'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 232 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 16 ms 2736 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 4312 KB Output is correct
2 Correct 31 ms 4804 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 98 ms 15576 KB Output is correct
6 Incorrect 99 ms 15564 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -