# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
966194 | 2024-04-19T13:55:22 Z | AkibAzmain | 사탕 분배 (IOI21_candies) | C++17 | 146 ms | 24640 KB |
#include "candies.h" #include <bits/stdc++.h> using namespace std; using ll = long long; std::vector<int> distribute_candies (std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { ll n = c.size(); v.push_back (0); vector < ll > a; for (auto &x : v) a.push_back (x); reverse (a.begin (), a.end ()); a.push_back (-1e18); for (auto &x : a) x *= -1; for (int i = 1; i < a.size (); ++i) a[i] += a[i - 1]; ll mn = 0, mx = 0; vector < ll > mna (a.size ()), mxa = mna; map < ll, int > mp; for (int i = 0; i < a.size (); ++i) { mna[i] = mn = min (mn, a[i]); mxa[i] = mx = max (mx, a[i]); if (mp.count (mx - mn) == 0) mp[mx - mn] = i; } vector < int > ans (n); for (int i = 0; i < n; ++i) { int j = mp.lower_bound (c[i])->second; if (a[j] == mna[j]) ans[i] = c[i] - mxa[j]; else ans[i] = -mna[j]; if (ans[i] < 0) ans[i] += c[i]; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 360 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 146 ms | 24552 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 48 ms | 10832 KB | Output is correct |
4 | Correct | 42 ms | 2936 KB | Output is correct |
5 | Correct | 86 ms | 12352 KB | Output is correct |
6 | Correct | 87 ms | 12228 KB | Output is correct |
7 | Correct | 91 ms | 12692 KB | Output is correct |
8 | Correct | 97 ms | 12244 KB | Output is correct |
9 | Correct | 146 ms | 24640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 360 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |