# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011180 | 2024-06-30T04:24:50 Z | doducanh | Sails (IOI07_sails) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define h first #define k second const int maxn=1e5; pair<int,int>a[maxn+7]; int dem[maxn+7]; int n; struct BIT{ int n; vector<int>t; BIT(){} BIT(int n):n(n),t(n+7,0){} void up(int x,int val){ for(;x<=n;x+=(x&(-x)))t[x]+=val; } int get(int x){ int ans=0; for(;x;x-=(x&(-x)))ans+=t[x]; return ans; } }; main() { freopen("sail.inp","r",stdin); cin>>n; for(int i=1;i<=n;i++)cin>>a[i].h>>a[i].k; sort(a+1,a+n+1); BIT t(a[n].h); // for(int i=1;i<=n;i++){ // cout<<a[i].h<<" "<<a[i].k<<"\n"; // } for(int i=1;i<=n;i++){ int h=a[i].h,k=a[i].k; int val=t.get(h-k); int l=1,r=h; int res=1; while(l<=r){ int m=(l+r)/2; if(t.get(m)<=val){ res=m; r=m-1; } else l=m+1; } int left=res; l=1,r=h; res=h+1; while(l<=r){ int m=(l+r)/2; if(t.get(m)>=val){ res=m; l=m+1; } else r=m-1; } int right=res; if(h==k)right=0; t.up(right+1,1); t.up(h+1,-1); t.up(left,1); t.up(left+(k-(h-right)),-1); } int ans=0; for(int i=1;i<=a[n].h;i++){ int x=t.get(i); ans+=(x)*(x-1)/2; } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |