Submission #434264

# Submission time Handle Problem Language Result Execution time Memory
434264 2021-06-20T20:41:16 Z madlogic Jelly Flavours (IOI20_jelly) C++17
0 / 100
79 ms 380 KB
#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;

int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
  int n = (int) a.size();
  vector<pair<int, int>> jellies(n);
  for (int i = 0; i < n; i++) {
    jellies[i].first = a[i];
    jellies[i].second = b[i];
  }
  sort(jellies.begin(), jellies.end());
  vector<int> pref(n), suff(n);
  for (int i = 0; i < n; i++) {
    vector<int> v;
    for (int j = 0; j < i; j++) {
      v.push_back(jellies[j].second);
    }
    sort(v.begin(), v.end());
    int tmp = y;
    int cnt = 0;
    for (int& cost : v) {
      if (tmp - cost >= 0) {
        ++cnt;
        tmp -= cost;
      }
    }
    pref[i] = cnt;
  }
  for (int i = n - 1; i >= 0; i--) {
    vector<int> v;
    for (int j = i; j < n; j++) {
      v.push_back(jellies[j].second);
    }
    sort(v.begin(), v.end());
    int tmp = y;
    int cnt = 0;
    for (int& cost : v) {
      if (tmp - cost >= 0) {
        ++cnt;
        tmp -= cost;
      }
    }
    suff[i] = cnt;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      if (sum + jellies[j].first > x)  {
        break;
      }
      sum += jellies[j].first;
      res = max(res, (j - i + 1) + (i > 0 ? pref[i - 1] : 0) + (j + 1 < n ? suff[j + 1] : 0));
    }
  } 
  return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 332 KB 1st lines differ - on the 1st token, expected: '689', found: '683'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 372 KB Output is correct
2 Correct 52 ms 380 KB Output is correct
3 Correct 52 ms 360 KB Output is correct
4 Correct 48 ms 352 KB Output is correct
5 Correct 51 ms 364 KB Output is correct
6 Correct 47 ms 368 KB Output is correct
7 Correct 51 ms 332 KB Output is correct
8 Correct 60 ms 368 KB Output is correct
9 Correct 49 ms 332 KB Output is correct
10 Correct 52 ms 360 KB Output is correct
11 Correct 50 ms 332 KB Output is correct
12 Correct 48 ms 332 KB Output is correct
13 Correct 53 ms 368 KB Output is correct
14 Correct 59 ms 332 KB Output is correct
15 Incorrect 60 ms 360 KB 1st lines differ - on the 1st token, expected: '1222', found: '1716'
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 332 KB 1st lines differ - on the 1st token, expected: '154', found: '161'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '7'
2 Halted 0 ms 0 KB -