# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
141596 |
2019-08-08T13:30:28 Z |
stefdasca |
Sails (IOI07_sails) |
C++14 |
|
41 ms |
1548 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;
typedef long long ll;
struct hei
{
int h, ct;
};
hei v[100002];
bool cmp(hei a, hei b)
{
if(a.h == b.h)
return a.ct > b.ct;
return a.h > b.h;
}
int n, aib[100002];
ll ans = 0;
void update(int nod, int val)
{
for(; nod <= 100000; nod += (nod & (-nod)))
aib[nod] += val;
}
int compute(int nod)
{
int ans = 0;
for(; nod; nod -= (nod & (-nod)))
ans += aib[nod];
return ans;
}
ll gauss(int n)
{
return 1LL * n * (n-1) / 2;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> v[i].h >> v[i].ct;
sort(v+1, v+n+1, cmp);
int r = 100000;
for(int i = 1; i <= n; ++i)
{
while(v[i].h < r)
ans += gauss(compute(r)), --r;
/*
int val = compute(v[i].ct);
int st = v[i].ct + 1;
int dr = r;
int lst = v[i].ct;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(compute(mid) == val)
lst = mid, st = mid + 1;
else
dr = mid - 1;
}
int fi = v[i].ct - 1;
st = 1;
dr = v[i].ct - 1;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(compute(mid) == val)
fi = mid - 1, dr = mid - 1;
else
st = mid + 1;
}
update(1, 1);
update(fi + 1, -1);
v[i].ct -= fi;
update(lst + 1, -1);
update(lst - v[i].ct + 1, 1);
*/
update(r - v[i].ct + 1, 1);
update(r + 1, -1);
/*
for(int j = 1; j <= r; ++j)
cout << compute(j) << " ";
cout << '\n';
*/
}
while(r)
ans += gauss(compute(r)), --r;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
632 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
888 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
1240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
1372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
1548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |