国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【Codefroces 717 C. Potions Homework】

2019-11-08 02:53:41
字體:
來源:轉載
供稿:網友

C. Potions Homework time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class teacher, PRofessor Snipe is sulky as usual. Due to his angst fueled by disappointment in his own life, he has given them a lot of homework in Potions class.

Each of the n students has been assigned a single task. Some students do certain tasks faster than others. Thus, they want to redistribute the tasks so that each student still does exactly one task, and that all tasks are finished. Each student has their own laziness level, and each task has its own difficulty level. Professor Snipe is trying hard to improve their work ethics, so each student’s laziness level is equal to their task’s difficulty level. Both sets of values are given by the sequence a, where ai represents both the laziness level of the i-th student and the difficulty of his task.

The time a student needs to finish a task is equal to the product of their laziness level and the task’s difficulty. They are wondering, what is the minimum possible total time they must spend to finish all tasks if they distribute them in the optimal way. Each person should receive one task and each task should be given to one person. Print the answer modulo 10?007.

Input The first line of input contains integer n (1?≤?n?≤?100?000) — the number of tasks. The next n lines contain exactly one integer number ai (1?≤?ai?≤?100?000) — both the difficulty of the initial task and the laziness of the i-th students.

Output Print the minimum total time to finish all tasks modulo 10?007.

Example input 2 1 3 output 6 Note In the first sample, if the students switch their tasks, they will be able to finish them in 3?+?3?=?6 time units.

時間 = 懶惰程度 × 難度系數

最少時間 = sort?

AC代碼:

#include<cstdio>#include<algorithm>using namespace std;typedef long long LL;const int mod = 10007;const int K = 1e5 + 10;LL a[K];int main(){ int N; scanf("%d",&N); for(int i = 1 ; i <= N; i++) scanf("%lld",&a[i]); sort(a + 1, a + 1 + N); LL ans = 0; for(int i = 1 ; i <= N; i++) ans = (ans + a[i] * a[N - i + 1]) % mod; printf("%lld/n",ans); return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沿河| 永登县| 读书| 武冈市| 米泉市| 湛江市| 承德市| 右玉县| 渑池县| 黑水县| 临潭县| 宣恩县| 南宁市| 乌拉特前旗| 长岭县| 乐业县| 绥化市| 吉林市| 沅陵县| 金塔县| 南华县| 浦城县| 宽城| 镇康县| 锡林郭勒盟| 平乐县| 龙江县| 从江县| 肃北| 昌黎县| 昌乐县| 阜阳市| 南丹县| 精河县| 竹溪县| 南投市| 大同县| 开化县| 河源市| 江安县| 华阴市|