Submission #587295

# Submission time Handle Problem Language Result Execution time Memory
587295 2022-07-01T15:33:01 Z jakubd Distributing Candies (IOI21_candies) C++17
11 / 100
97 ms 12880 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(n);
 
  if (n <= 2000 && q <= 2000) {
    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 {
    vector<long long> pref(n + 10);
 
    for (int i = 0; i < q; i++) {
      pref[l[i]] += v[i];
      pref[r[i] + 1] -= v[i];
    }
 

    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum += pref[i];
      s[i] = min(sum, (long long) c[i]);
    }
  }
 
  return s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 8896 KB Output is correct
2 Correct 91 ms 12880 KB Output is correct
3 Correct 92 ms 12756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 53 ms 4960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 50 ms 4952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 3 ms 340 KB Output is correct
6 Correct 97 ms 8896 KB Output is correct
7 Correct 91 ms 12880 KB Output is correct
8 Correct 92 ms 12756 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 53 ms 4960 KB Output isn't correct
11 Halted 0 ms 0 KB -