답안 #848208

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848208 2023-09-11T15:14:01 Z vjudge1 Unija (COCI17_unija) C++17
10 / 100
133 ms 5208 KB
/*
                                  ⢀⡴⠑⡄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣤⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                                  ⠸⡇⠀⠿⡀⠀⠀⠀⣀⡴⢿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠑⢄⣠⠾⠁⣀⣄⡈⠙⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⢀⡀⠁⠀⠀⠈⠙⠛⠂⠈⣿⣿⣿⣿⣿⠿⡿⢿⣆⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⢀⡾⣁⣀⠀⠴⠂⠙⣗⡀⠀⢻⣿⣿⠭⢤⣴⣦⣤⣹⠀⠀⠀⢀⢴⣶⣆
                                  ⠀⠀⢀⣾⣿⣿⣿⣷⣮⣽⣾⣿⣥⣴⣿⣿⡿⢂⠔⢚⡿⢿⣿⣦⣴⣾⠁⠸⣼⡿
                                  ⠀⢀⡞⠁⠙⠻⠿⠟⠉⠀⠛⢹⣿⣿⣿⣿⣿⣌⢤⣼⣿⣾⣿⡟⠉⠀⠀⠀⠀⠀
                                  ⠀⣾⣷⣶⠇⠀⠀⣤⣄⣀⡀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
                                  ⠀⠉⠈⠉⠀⠀⢦⡈⢻⣿⣿⣿⣶⣶⣶⣶⣤⣽⡹⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⠀⠉⠲⣽⡻⢿⣿⣿⣿⣿⣿⣿⣷⣜⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣶⣮⣭⣽⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
                                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⠿⠿⠿⠛⠉
*/
#include <bits/stdc++.h>
#pragma GCC optimize("O3","unroll-loops")
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define endl '\n'
#define pb(v,i) (v).push_back(i)
#define vll vector<ll>
#define pll pair<ll,ll>
#define map unordered_map
typedef long long ll;

__int128 fastpow(ll base,ll exp){__int128 result=1;while (exp){if (exp%2==1) result*=base;exp/=2;base*=base;}return result;}
bool isprime(ll x){for (ll i=2;i*i<=x;i++){if (x%i==0) return false;}return true;}
string print128(__int128 r){string s="";while (r){s.push_back(r%10 + '0');r/=10;}reverse(s.begin(),s.end());return s;}
__int128 myownabs(__int128 r){if (r<0) return -r; return r;}
// bool issorted(auto i, auto j){ i++; for (;i!=j;i++){if (*i<*(i-1)) return 0;}return 1;}
bool cmp(ll i, ll j){ return i>j;}
bool cmp2(pll i, pll j){ // for task specific sorts
  if (i.first==j.first) return i.second > j.second;
  return i.first<j.first;
}

vector<vector<ll>>x(100004), y(100004);
ll inx[100004], iny[100004];

void solve(){
  ll n; cin >> n;
  ll maxh=0,maxw=0,maxhw=0,maxwh=0;
  ll ans=0;
  while (n--){
    ll h,w; cin >> h >> w;

    if ( (h>maxh && w>maxw) || (h==maxh && w==maxw) || (h>maxh && w==maxhw) || (h==maxwh && w>maxw) ){
      ans=h*w;
      maxh=h;
      maxhw=w;
      maxw=w;
      maxwh=h;
    }
    else if (h>maxh){
      ans+=(h-maxh)*w;
      maxh=h;
      maxhw=w;
    }
    else if (w>maxw){
      ans+=(w-maxw)*h;
      maxw=w;
      maxwh=h;
    }
    else if (h==maxh && w>maxhw){
      ans+= w - maxhw;
      maxw=w;
      maxwh=h;
    }
    else if (w==maxw && h>maxwh){
      ans+= h - maxwh;
      maxw=w;
      maxwh=h;
    }
  }
  cout << ans;
}
signed main(){
  fastio
  ll t=1;
  //cin >> t;
  for (int i=1;i<=t;i++){
      solve();
      cout << endl;
  }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 5208 KB Output is correct
3 Correct 2 ms 5172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 5156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 5148 KB Output isn't correct
2 Halted 0 ms 0 KB -