#include <bits/stdc++.h>
#define N 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll read()
{
char c=getchar();bool flag=0;ll x=0;
while(c<'0'||c>'9'){if(c=='-')flag=1;c=getchar();}
while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?-x:x;
}
struct gan{
ll h,s;
}a[N];
struct ceng{
ll num,val,sum;
}b[N];
bool cmp(gan a,gan b)
{
if(a.h<b.h) return 1;
return 0;
}
bool cmp2(ceng a,ceng b)
{
if(a.val<b.val) return 1;
return 0;
}
ll n,mx;
int main()
{
n=read(),mx=0;
for(ll i=1;i<=n;i++)
{
a[i].h=read(),a[i].s=read();
mx=max(mx,a[i].s);
}
for(ll i=1;i<=mx;i++) b[i].num=i;
sort(a+1,a+1+n,cmp);
for(ll i=1;i<=n;i++)
{
sort(b+1,b+1+a[i].s,cmp2);
for(ll j=1;j<=a[i].s;j++) b[i].val++,b[i].sum+=(b[i].val-1);
}
ll ans=0;
for(ll i=1;i<=n;i++) ans+=b[i].sum;
printf("%lld",ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
230 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
1016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
1528 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1045 ms |
2296 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1058 ms |
3832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
4088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
4216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |