#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf=1e18;
const ld pai=acos(-1);
ll n;
map<ll,ll>mp;
int main(){
cin>>n;
for(int i=0;i<n;i++){
ll x,y;
cin>>x>>y;
mp[x]=max(mp[x],y);
}
vpll v;
v.pb({0ll,0ll});
for(auto u:mp)v.pb(u);
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
ll mx=0,crnt=0;
for(ll i=0;i<v.size()-1;i++){
mx=max(mx,v[i].se);
crnt+=mx*(v[i].fi-v[i+1].fi);
}
cout<<crnt<<endl;
}
Compilation message
unija.cpp: In function 'int main()':
unija.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=0;i<v.size()-1;i++){
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
760 KB |
Output is correct |
2 |
Correct |
11 ms |
760 KB |
Output is correct |
3 |
Correct |
11 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
36732 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
2812 KB |
Output is correct |
2 |
Correct |
43 ms |
2808 KB |
Output is correct |
3 |
Correct |
47 ms |
2756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
8688 KB |
Output is correct |
2 |
Correct |
164 ms |
8560 KB |
Output is correct |
3 |
Correct |
199 ms |
8684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
583 ms |
22888 KB |
Output is correct |
2 |
Correct |
608 ms |
22932 KB |
Output is correct |
3 |
Correct |
585 ms |
22824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1098 ms |
37172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |