# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863396 |
2023-10-20T06:58:11 Z |
8pete8 |
Sails (IOI07_sails) |
C++14 |
|
70 ms |
2636 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define vi vector<int>
#define pb push_back
//#define p push
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define int long long
const int mod=9901,mxn=2*1e5+5,inf=1e18,lg=25,minf=-1e18;
int fwk[mxn+10];
void update(int pos,int val){for(int i=pos;i<mxn;i+=(i&-i))fwk[i]+=val;}
int qry(int pos){
int sum=0;
for(int i=pos;i>0;i-=(i&-i))sum+=fwk[i];
return sum;
}
int32_t main(){
int n;cin>>n;
vector<pii>v(n);
for(int i=0;i<n;i++)cin>>v[i].f>>v[i].s;
sort(all(v));
for(auto i:v){
int cmn=qry(i.f-i.s+1);
int l=1,r=i.f-i.s+1,pos=1e18;
while(l<=r){
int mid=l+(r-l)/2;
if(qry(mid)<=cmn)r=mid-1,pos=min(pos,mid);
else l=mid+1;
}
update(pos,1);
update(min(i.f+1,pos+i.s),-1);
if(i.f-pos+1>=i.s)continue;
int diff=i.s-(min(i.f+1,pos+i.s)-pos);
cmn=qry(pos-diff);
l=1,r=pos-diff;
int pos2=1e18;
while(l<=r){
int mid=l+(r-l)/2;
if(qry(mid)<=cmn)r=mid-1,pos2=min(pos2,mid);
else l=mid+1;
}
update(pos2,1);
update(pos2+diff,-1);
}
int ans=0,k;
for(int i=1;i<mxn;i++){
k=qry(i)-1;
ans+=(k*(k+1))/2;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
1172 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
2128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
2624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |