Submission #548624

# Submission time Handle Problem Language Result Execution time Memory
548624 2022-04-14T03:01:26 Z cig32 Distributing Candies (IOI21_candies) C++17
0 / 100
5000 ms 14504 KB
#include "candies.h"
#include "bits/stdc++.h"
using namespace std;

#include <cassert>
#include <cstdio>
#include <vector>


std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
  int n = c.size();
  std::vector<int> s(n);
  int q = l.size();
  int p[n], invp[n];
  pair<int, int> d[n];
  for(int i=0; i<n; i++) d[i] = {c[i], i};
  sort(d, d + n);
  for(int i=0; i<n; i++) p[i] = 0, invp[i] = d[i].first;
  for(int i=0; i<q; i++) {
    for(int j=0; j<n; j++) {
      p[j] += v[i];
      invp[j] -= v[i];
      if(p[j] < 0) {
        p[j] = 0, invp[j] = d[j].first;
      }
      if(invp[j] < 0) {
        invp[j] = 0, p[j] = d[j].first;
      }
    }
  }
  for(int i=0; i<n; i++) s[d[i].second] = p[i];
  return s;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5031 ms 14504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 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 570 ms 7680 KB Output is correct
4 Correct 595 ms 7136 KB Output is correct
5 Execution timed out 5047 ms 13552 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -