# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
203985 |
2020-02-23T12:32:24 Z |
awlintqaa |
Sails (IOI07_sails) |
C++14 |
|
100 ms |
3832 KB |
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 200
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf= 4e18;
const ld pai=acos(-1);
ll n , MX = 1e5;
pll a [100009];
ll sum[100009];
void upd ( ll l, ll r ){
sum [l] ++ ;
sum [r+1] -- ;
}
ll calc( ll x ){
if ( x ==0 ) return 0 ;
return x * (x-1ll) /2ll ;
}
int main () {
cin >> n ;
for ( int i =0 ;i < n;i ++ ) {
cin >> a[i].fi >> a[i].se;
}
sort ( a, a +n ) ;
ll last = 0 ;
for ( ll i =0 ;i < n; i ++ ) {
ll k = a[i].se ;
ll h = a[i].fi ;
ll l = last +1 ;
ll r = min ( l + k - 1 , h ) ;
if ( l <= r ) {
upd ( l, r ) ;
}
ll X = k - (r-l+1) ;
if ( X > 0 ) {
l = 1 ;
r = l + X -1 ;
if ( l <= r ){
upd ( l,r );
}
}
last = r ;
}
for ( ll i =1 ;i <= MX ;i ++ ) {
sum [i] += sum[i-1];
}
ll ans =0 ;
for ( ll i =0 ;i <= MX ;i ++ ) {
ans += calc ( sum [i] ) ;
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
1912 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
2456 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
84 ms |
3192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
89 ms |
3576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
100 ms |
3832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |