#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue>
using namespace std;
int n,h,k,height,mini,s,c;
struct smg
{
int 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 |
376 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 |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
532 ms |
404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
888 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
1148 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1042 ms |
1708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
1832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
1836 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |