Submission #587251

# Submission time Handle Problem Language Result Execution time Memory
587251 2022-07-01T14:21:30 Z jakubd Distributing Candies (IOI21_candies) C++17
3 / 100
109 ms 8248 KB
#include "candies.h"
 
#include <bits/stdc++.h>
 
using namespace std;
 
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
  int n = c.size(), q = (int)l.size();
  vector<int> s;
 
  if (n <= 2000 && q <= 2000) {
    s.resize(n);
 
    for (int i = 0; i < q; i++) {
      for (int j = l[i]; j <= r[i]; j++) {
        s[j] += v[i];
 
        if (s[j] < 0) s[j] = 0;
        if (s[j] > c[j]) s[j] = c[j];
      }
    }
  } else {
    s.resize(n + 1);
 
    for (int i = 0; i < q; i++) {
      s[l[i]] += v[i];
      s[r[i] + 1] -= v[i];
    }
 
    for (int i = 0; i < n; i++) s[i + 1] += s[i];
 
    vector<int> res(n);
    for (int i = 0; i < n; i++) {
      res[i] = min(s[i + 1], c[i]);
    }

    s = res;
  }
 
  return s;
}
# 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 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 8248 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 Incorrect 54 ms 4964 KB Output isn't correct
3 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 48 ms 5072 KB Output isn't correct
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 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Incorrect 109 ms 8248 KB Output isn't correct
7 Halted 0 ms 0 KB -