結果
問題 | No.1416 ショッピングモール |
ユーザー |
|
提出日時 | 2021-03-05 21:33:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 2,912 bytes |
コンパイル時間 | 1,031 ms |
コンパイル使用メモリ | 102,552 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-07 00:43:04 |
合計ジャッジ時間 | 1,813 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES#include <iostream> // cout, endl, cin#include <cstdio> // printf, scanf#include <string> // string, to_string, stoi#include <algorithm> // min, max, swap, lower_bound, upper_bound// & stable_sort, sort, reverse#include <cmath> //sin(rad),cos,tan, abs, pow, sqrt, cbrt, exp, log, log10, log2#include <utility> // pair, make_pair#include <map> // map#include <set> // set#include <vector> // vector#include <queue> // queue, priority_queue#include <stack> // stack#include <list> // list#include <deque> // deque#include <iomanip>#include <numeric>#include <string.h>#include <stdio.h>#include <stdlib.h>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef vector<int> vi;typedef vector<string> vs;typedef pair<int, int> pii;typedef pair<string, int> psi;typedef pair<int, string> pis;typedef set<int> si;typedef map<string, int> msi;typedef map<string, bool> msb;typedef priority_queue<int> pqi;typedef stack<int> sti;typedef queue<int> qi;#define infi 1147483647#define infl 9223372036854775806#define MOD 1000000007#define EPS 0.0000000001#define rep(i,n) for(int i=0;i<(int)n;i++)#define repa(i,n) for(int i=1;i<=(int)n;i++)#define irep(i,n) for(int i=(int)n-1;i>=0;i--)using std::cin;using std::string;template <typename T>T in() {T temp; cin >> temp; return temp;}template <>int in() {int temp; (void)scanf("%d", &temp); return temp;}template <>double in() {double temp; (void)scanf("%lf", &temp); return temp;}template <>char in() {char temp; (void)scanf("%c", &temp); return temp;}template<typename T1, typename T2>constexpr auto equals(T1 a, T2 b) { return (fabs(a - b) < EPS); }//その他便利なメソッドvoid clear(std::queue<int>& q){std::queue<int> empty;std::swap(q, empty);}bool compare_by_b(pair<int, int> a, pair<int, int> b) {if (a.second != b.second) {return a.second < b.second;}else {return a.first > b.first;}}//---------------------------------------------------vi a;int n;int main() {//int a = in<int>(); string b = in<string>(); char c = in<char>();//double d = in<double>();//(void)scanf("%d",&);//(void)scanf("%d%d",& ,&);cin >> n; int x;rep(i, n) {(void)scanf("%d", &x);a.push_back(x);}sort(a.begin(), a.end(), greater<int>());int k = 0;ll sum = 0;while (1) {for (int i = (int)pow(2, k); i < min((int)pow(2, k + 1), n + 1); i++) {sum += (ll)a[i - 1] * k;}k++;if ((int)pow(2, k) >= n) break;}std::cout << sum << endl;return 0;}