国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘城县| 奉化市| 大邑县| 鲁山县| 江西省| 万荣县| 卫辉市| 阿勒泰市| 武汉市| 孟连| 稷山县| 咸丰县| 兴化市| 南宁市| 敖汉旗| 若羌县| 抚顺县| 酉阳| 海城市| 姜堰市| 安义县| 高邮市| 裕民县| 仙居县| 屯门区| 洪江市| 东山县| 鄯善县| 双城市| 吴堡县| 玉龙| 黎城县| 五莲县| 沙坪坝区| 宁陵县| 甘德县| 内江市| 瑞昌市| 巨野县| 潼南县| 化州市|