# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
714698 |
2023-03-25T08:03:52 Z |
four_specks |
Sails (IOI07_sails) |
C++17 |
|
19 ms |
5640 KB |
#include <bits/stdc++.h>
using namespace std;
namespace
{
} // namespace
void solve()
{
const int X = 100'000;
int n;
cin >> n;
vector<long> a(n), b(n);
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
vector<long> run(X + 1);
for (int i = 0; i < n; i++)
{
run[b[i] - a[i]]++;
run[a[i]]--;
}
for (int x = 0; x < X; x++)
run[x + 1] += run[x];
stack<pair<long, int>> st;
for (int x = 0; x < X; x++)
{
long cur = run[x];
int cnt = 1;
while (!st.empty() && st.top().first <= run[x])
{
auto [x, y] = st.top();
st.pop();
cur += x * y;
cnt += y;
}
long q = cur / cnt, d = cur % cnt;
if (d > 0)
st.emplace(q + 1, d);
st.emplace(q, cnt - d);
}
long res = 0;
while (!st.empty())
{
auto [x, y] = st.top();
st.pop();
res += y * x * (x - 1) / 2;
}
cout << res << '\n';
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(NULL);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1988 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
2004 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1980 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2124 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
2260 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
3348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
3992 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
4900 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
5236 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
5640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |