| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1356936 | NAMIN | Sails (IOI07_sails) | C++20 | 13 ms | 1476 KiB |
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
const int mxN = 100005;
void solve(){
int N;
cin >> N;
vector<pair<int,int>> event(N);//h,k
for(int i=0;i<N;i++){
cin >> event[i].first >> event[i].second;
}
sort(event.rbegin(),event.rend());
vector<int> pref(mxN,0);
int p=event[0].first+1;
for(auto [h,k] : event){
p=min(h+1,p);
if(p<=k){
pref[1]++;
pref[p]--;
k-=p-1;
p=h+1;
}
if(k>0){
int nxtp = p-k;
pref[nxtp]++;
pref[p]--;
p-=k;
if(p==1)
p=h+1;
}
}
ll ans = 0;
for(int i=1;i<mxN;i++){
pref[i]+=pref[i-1];
ans+=1LL*(pref[i]-1)*pref[i]/2;
}
cout << ans << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin >> t;
while(t--){
solve();
}
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
