#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;
}
bool cmp3(ceng a,ceng b)
{
if(a.num<b.num) 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].h,cmp2);
for(ll j=1;j<=a[i].s;j++) b[j].val++,b[j].sum+=(b[j].val-1);
sort(b+1,b+1+mx,cmp3);
}
ll ans=0;
for(ll i=1;i<=mx;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 |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
765 ms |
488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
1452 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
2296 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
3832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1050 ms |
4088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
4252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |