@ -0,0 +1,11 @@
EXE=a.out
CC=g++
CFLAGS=-lm -lcrypt -O2 -std=c++11 -Wall -Wextra -Werror -pipe -DONLINE_JUDGE
OBJ=main.cpp
$(EXE): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ)
.PHONY: clean
clean:
rm -rf $(EXE)
@ -0,0 +1,29 @@
#include <vector>
#include <algorithm>
using std::vector;
using std::sort;
#include <cstdio>
int main()
{
int n;
scanf("%d\n", &n);
char c[256];
vector<double> pwds;
for (int i{0}; i < n; ++i) {
double p;
scanf("%s", c);
scanf("%lf\n", &p);
pwds.push_back(p);
}
sort(pwds.begin(), pwds.end());
double sum = 0;
int t = 1;
for (vector<double>::reverse_iterator i = pwds.rbegin(); i != pwds.rend(); ++i) {
sum += (double)t * (*i);
t++;
printf("%lf\n", sum);