# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
776161 |
2023-07-07T10:58:48 Z |
Ahmed57 |
Sails (IOI07_sails) |
C++17 |
|
1000 ms |
4632 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> v[100001];
for(int i = 0;i<n;i++){
int a,b;cin>>a>>b;
v[a].push_back(b);
}
long long l = 1 , r = 100000 , ans = -1;
while(l<=r){
int mid = (l+r)/2;
multiset<int> s;
long long all = 0;
priority_queue<int> ve;
for(int i = 100000;i>=1;i--){
for(auto j:v[i]){
ve.push(j);
}
long long sz = min(int(ve.size()),mid);
all+=(sz*(sz-1))/2;
vector<int> xd;
while(sz--){
xd.push_back(ve.top()-1);
ve.pop();
}
for(auto j:xd){if(j)ve.push(j);}
}
if(ve.empty()){
ans = all;
r = mid-1;
}else{
l = mid+1;
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2516 KB |
Output is correct |
2 |
Correct |
6 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2516 KB |
Output is correct |
2 |
Correct |
6 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2516 KB |
Output is correct |
2 |
Correct |
5 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
2684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
2836 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
3668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1046 ms |
3684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
3584 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
4632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
4600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |