Submission #728511

# Submission time Handle Problem Language Result Execution time Memory
728511 2023-04-22T14:40:13 Z kwongweng Catfish Farm (IOI22_fish) C++17
6 / 100
137 ms 18384 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second

ll max_weights(int n, int m, vi X, vi Y, vi W) {
  vii a0, a1;
  FOR(i,0,m){
    if (X[i] == 0) a0.pb({Y[i], W[i]});
    else a1.pb({Y[i], W[i]});
  }
  sort(a0.begin(), a0.end());
  sort(a1.begin(), a1.end());
  ll ans = 0;
  FOR(i,0,a1.size()){
    ans += a1[i].se;
  }
  if (n == 2){
    ll ans0 = 0;
    FOR(i,0,a0.size()){
      ans0 += a0[i].se;
    }
    return max(ans, ans0);
  }
  ll cur = ans;
  int j = 0;
  FOR(i,0,a0.size()){
    cur += a0[i].se;
    if (j >= a1.size()){
      ans = max(ans, cur);
      continue;
    }
    while (a0[i].fi >= a1[j].fi && j < a1.size()){
      cur -= a1[j].se; j++;
    }
    ans = max(ans, cur);
  }
  return ans;
}

Compilation message

fish.cpp: In function 'll max_weights(int, int, vi, vi, vi)':
fish.cpp:11:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   27 |   FOR(i,0,a1.size()){
      |       ~~~~~~~~~~~~~                    
fish.cpp:27:3: note: in expansion of macro 'FOR'
   27 |   FOR(i,0,a1.size()){
      |   ^~~
fish.cpp:11:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   32 |     FOR(i,0,a0.size()){
      |         ~~~~~~~~~~~~~                  
fish.cpp:32:5: note: in expansion of macro 'FOR'
   32 |     FOR(i,0,a0.size()){
      |     ^~~
fish.cpp:11:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   39 |   FOR(i,0,a0.size()){
      |       ~~~~~~~~~~~~~                    
fish.cpp:39:3: note: in expansion of macro 'FOR'
   39 |   FOR(i,0,a0.size()){
      |   ^~~
fish.cpp:41:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     if (j >= a1.size()){
      |         ~~^~~~~~~~~~~~
fish.cpp:45:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     while (a0[i].fi >= a1[j].fi && j < a1.size()){
      |                                    ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 4672 KB Output is correct
2 Correct 38 ms 5552 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 123 ms 17868 KB Output is correct
6 Incorrect 137 ms 18384 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 62 ms 8552 KB Output is correct
3 Correct 76 ms 10304 KB Output is correct
4 Correct 32 ms 4696 KB Output is correct
5 Correct 40 ms 5544 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 29 ms 4700 KB Output is correct
13 Correct 39 ms 5540 KB Output is correct
14 Correct 43 ms 4468 KB Output is correct
15 Correct 35 ms 4936 KB Output is correct
16 Correct 30 ms 4680 KB Output is correct
17 Correct 33 ms 5064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 20 ms 3096 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 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 Incorrect 1 ms 340 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 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 Incorrect 1 ms 340 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 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 Incorrect 1 ms 340 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 1 ms 212 KB Output is correct
3 Incorrect 20 ms 3096 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 30 ms 4672 KB Output is correct
2 Correct 38 ms 5552 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 123 ms 17868 KB Output is correct
6 Incorrect 137 ms 18384 KB 1st lines differ - on the 1st token, expected: '300000000000000', found: '299997000000000'
7 Halted 0 ms 0 KB -