답안 #201468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201468 2020-02-10T16:23:30 Z awlintqaa Unija (COCI17_unija) C++14
100 / 100
886 ms 65536 KB
#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;
unordered_map<ll,ll>mp;
int main(){
  fast;
        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:45: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 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 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 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 632 KB Output is correct
2 Correct 7 ms 632 KB Output is correct
3 Correct 7 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 800 ms 58572 KB Output is correct
2 Correct 813 ms 65536 KB Output is correct
3 Correct 810 ms 65536 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 17 ms 1908 KB Output is correct
2 Correct 17 ms 1912 KB Output is correct
3 Correct 17 ms 1908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 6148 KB Output is correct
2 Correct 53 ms 6148 KB Output is correct
3 Correct 51 ms 6140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 205 ms 17108 KB Output is correct
2 Correct 185 ms 17032 KB Output is correct
3 Correct 215 ms 17024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 814 ms 58332 KB Output is correct
2 Correct 886 ms 65536 KB Output is correct
3 Correct 769 ms 65536 KB Output is correct