#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
ll n,h,k,height,mini,s,c;
struct smg
{
ll h,k;
}f[100001],flagged[100001];
bool cmp(smg a,smg b)
{
return a.h<b.h;
}
bool cmp2(smg a,smg b)
{
return a.h<b.h;
}
bool cmp3(smg a,smg b)
{
return a.k<b.k;
}
int main(void)
{
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>h>>k;height=max(h,height);f[i].h=h;f[i].k=k;
}
sort(f+1,f+n+1,cmp);
for (int i=1;i<=height;i++) flagged[i].k=i;
for (int i=1;i<=n;i++)
{
sort(flagged+1,flagged+f[i].h+1,cmp2);
for (int j=1;j<=f[i].k;j++)
{
flagged[j].h++;
}
}
for (int i=1;i<=height;i++) s+=(flagged[i].h-1)*flagged[i].h/2;
cout<<s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
557 ms |
480 KB |
Output is correct |
2 |
Execution timed out |
1077 ms |
1912 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
1016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
1628 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
2296 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
3488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
3684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
3896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |