Submission #481981

#TimeUsernameProblemLanguageResultExecution timeMemory
481981Aditya_A_garwalBest Place (NOI17_bestplace)C++17
100 / 100
86 ms3020 KiB
// Krishnaya vaasudevaya // Devaki nandanayacha // Nanda gopakumaraya // Govindaya namoh namaha // Jay ganeshji, Jay Guruji, Jay Ram-bhakt Hanumanji #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define ff first #define ss second #define pb emplace_back #define eb emplace // Competion only using namespace std; using namespace __gnu_pbds; using ll = long long; using ull = unsigned ll; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vii = vector<pii>; using vll = vector<pll>; const int inf = 1e9 + 7; const ll llinf = 1e18 + 7; constexpr ll mod = 1e9 + 7; const vector<pii> dirs4 = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}; const vector<pii> dirs8 = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; ll fastPow(ll a, ll b) { ll res = 1; while(b) { if(b & 1) res *= a; a *= a, b >>= 1; } return res; } ll fastPow(ll a, ll b, ll m) { ll res = 1; a %= m; while(b) { if(b & 1) (res *= a) %= m; (a *= a) %= m, b >>= 1; } return res; } ll modinv(ll x, ll m) { return fastPow(x, m - 2, m); } ll moddiv(ll numerator, ll denominator, ll m) { return numerator * modinv(denominator, m); } template<typename T> inline void maximize(T &trg, T src) { trg = max(trg, src); } template<typename T> inline void minimize(T &trg, T src) { trg = min(trg, src); } template<typename T> constexpr ostream &operator<<(ostream &stream, const vector<T> &other) { stream << '['; size_t n = other.size(); if(n > 0) { for(size_t i = 0; i < n - 1; i++) stream << other[i] << ", "; stream << other[n - 1]; } return stream << ']'; } template<typename T> constexpr ostream &operator<<(ostream &stream, const set<T> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << *it << ", ", ++it; stream << *it; } return stream << '}'; } template<typename T> constexpr ostream &operator<<(ostream &stream, const multiset<T> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << *it << ", ", ++it; stream << *it; } return stream << '}'; } template<typename T> constexpr ostream &operator<<(ostream &stream, const ordered_set<T> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << *it << ", ", ++it; stream << *it; } return stream << '}'; } template<typename T1, typename T2> constexpr ostream &operator<<(ostream &stream, const map<T1, T2> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << (*it).first << ':' << (*it).second << ", ", ++it; stream << (*it).first << ':' << (*it).second; } return stream << '}'; } template<typename T1, typename T2> constexpr ostream &operator<<(ostream &stream, const multimap<T1, T2> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << (*it).first << ':' << (*it).second << ", ", ++it; stream << (*it).first << ':' << (*it).second; } return stream << '}'; } template<typename T1, typename T2> constexpr ostream &operator<<(ostream &stream, const unordered_map<T1, T2> &other) { stream << '{'; size_t n = other.size(); if(n > 0) { auto it = other.begin(); for(size_t i = 0; i < n-1; i++) stream << (*it).first << ':' << (*it).second << ", ", ++it; stream << (*it).first << ':' << (*it).second; } return stream << '}'; } template<typename T1, typename T2> constexpr ostream &operator<<(ostream &stream, const pair<T1, T2> &other) { return stream << '(' << other.first << ", " << other.second << ')'; } template<typename T> istream &operator>>(istream &stream, vector<T> &other) { for(auto &e : other) stream >> e; return stream; } template<typename T1, typename T2> istream &operator>>(istream &stream, pair<T1, T2> &other) { stream >> other.first >> other.second; return stream; } template<size_t I = 0, typename ...T> ostream &operator<<(ostream &stream, const tuple<T...> &other) { if constexpr(I == 0) stream << '('; stream << get<I>(other); if constexpr(I < sizeof...(T) - 1) { stream << ", "; return operator<<<I + 1>(stream, other); } return stream << ')'; } inline void solve() { int n; cin >> n; vii ar(n); cin >> ar; pii res; sort(ar.begin(), ar.end()); res.ff = ar[n >> 1].ff; for(auto &e : ar) swap(e.ff, e.ss); sort(ar.begin(), ar.end()); res.ss = ar[n >> 1].ff; cout << res.ff << ' ' << res.ss << endl; } int main(int argc, char *argv[]) { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...