Submission #1020457

# Submission time Handle Problem Language Result Execution time Memory
1020457 2024-07-12T05:02:37 Z NeroZein Distributing Candies (IOI21_candies) C++17
11 / 100
5000 ms 16488 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 = (int) c.size(), q = (int) l.size();
    vector<int> s(n);
    vector<long long> add(n), sub(n); 
    bool pos = true; 
    for (int i = 0; i < q; ++i) {
      pos &= v[i] > 0;
      add[l[i]] += v[i];
      sub[r[i]] += v[i];
    }
    if (pos) {
      long long sum = 0; 
      for (int i = 0; i < n; ++i) {
        sum += add[i];
        s[i] = min((long long) c[i], sum); 
        sum -= sub[i];
      }
    } else {
      for (int i = 0; i < q; ++i) {
        for (int j = l[i]; j <= r[i]; ++j) {
          s[j] = s[j] + v[i];
          s[j] = max(s[j], 0);
          s[j] = min(s[j], c[j]); 
        }
      }
    }
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 15444 KB Output is correct
2 Correct 63 ms 14672 KB Output is correct
3 Correct 64 ms 14424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 179 ms 8160 KB Output is correct
3 Correct 189 ms 7944 KB Output is correct
4 Execution timed out 5063 ms 16488 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 458 ms 7780 KB Output is correct
4 Correct 518 ms 7160 KB Output is correct
5 Execution timed out 5053 ms 13876 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 70 ms 15444 KB Output is correct
7 Correct 63 ms 14672 KB Output is correct
8 Correct 64 ms 14424 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 179 ms 8160 KB Output is correct
11 Correct 189 ms 7944 KB Output is correct
12 Execution timed out 5063 ms 16488 KB Time limit exceeded
13 Halted 0 ms 0 KB -