# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1105600 |
2024-10-27T01:10:45 Z |
Faggi |
Sails (IOI07_sails) |
C++11 |
|
44 ms |
9328 KB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5;
const int MAXS = 262144;
ll seg[MAXS], dp[MAXN], vf[MAXN],pot=131072, dpCalc[MAXN+1];
void calc(ll x, ll nod)
{
if (nod >= pot)
{
vf[nod - pot] = x;
return;
}
ll iz, der, mid, maD;
mid = x / 2ll;
iz = mid;
der = mid;
if (der + der < x)
der++;
maD = seg[nod * 2 + 1];
if (maD < der)
{
iz += der - maD;
der = maD;
}
if (iz > 0)
calc(iz, nod * 2);
if (der > 0)
calc(der, nod * 2 + 1);
}
int main()
{
ll n, i, tot = 0, a, b, res = 0, lim;
cin >> n;
for (i = 2; i <= MAXN; i++)
{
dpCalc[i] = dpCalc[i - 1] + (i - 1);
}
for (i = 0; i < n; i++)
{
cin >> a >> b;
lim = a - b;
lim--;
tot += b;
a--;
dp[a]++;
if (lim >= 0)
dp[lim]--;
}
for (i = MAXN - 2; i >= 0; i--)
{
dp[i] += dp[i + 1];
}
for (i = pot; i < MAXS; i++)
{
seg[i] = dp[i - pot];
}
for (i = pot - 1; i > 0; i--)
{
seg[i] = seg[i * 2] + seg[i * 2 + 1];
}
calc(tot, 1);
for (i = MAXN - 1; i >= 0; i--)
{
res += dpCalc[vf[i]];
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4688 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4688 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4688 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
9296 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
4700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
9296 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
9328 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
9324 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
44 ms |
9328 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |