2018ccpc_hn

Posted jaydenouyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018ccpc_hn相关的知识,希望对你有一定的参考价值。

A. Easy h-index

技术分享图片
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <string>
 6 #include <map>
 7 #include <cmath>
 8 #include <vector>
 9 
10 #define Faster ios::sync_with_stdio(false),cin.tie(0)
11 #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
12 #define Close fclose(stdin),fclose(stdout)
13 const int maxn = 2*1e5 + 5;
14 using namespace std;
15 const int MOD = 1e9+7;
16 typedef long long ll;
17 
18 int a[maxn];
19 
20 int main(){
21     Faster;
22     int n;
23     while(cin >> n){
24         for(int i = 0;i <= n;i++){
25             cin >> a[i];
26         }
27     
28         int sum = 0;
29         int h = n+1;
30         while(sum < h){
31             sum += a[--h];
32         }
33         cout << h << endl;
34     }
35     return 0;
36 }
View Code

 

B. Higher h-index

技术分享图片
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <string>
 6 #include <map>
 7 #include <cmath>
 8 #include <vector>
 9 
10 #define Faster ios::sync_with_stdio(false),cin.tie(0)
11 #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
12 #define Close fclose(stdin),fclose(stdout)
13 const int maxn = 2*1e5 + 5;
14 using namespace std;
15 const int MOD = 1e9+7;
16 typedef long long ll;
17 
18 int a[maxn];
19 
20 int main(){
21     Faster;
22     int n, a;
23     while(cin >> n >> a){
24         if(n < a)
25             cout << n << endl;
26         else{
27             int h = a + (n-a)/2; 
28             cout << h << endl;
29         }
30     }
31     return 0;
32 }
View Code

 

F. Sorting

技术分享图片
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <string>
 6 #include <map>
 7 #include <cmath>
 8 #include <vector>
 9 
10 #define Faster ios::sync_with_stdio(false),cin.tie(0)
11 #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
12 #define Close fclose(stdin),fclose(stdout)
13 const int maxn = 1e3+5;
14 using namespace std;
15 const int MOD = 1e9+7;
16 typedef long long ll;
17 
18 struct node
19 {
20     ll a,b,c;
21     int id;
22 }t[maxn];
23 
24 bool cmp(node x, node y){
25     ll xx = x.a*y.c + x.b*y.c;
26     ll yy = y.a*x.c + y.b*x.c;
27     if(xx == yy)
28         return x.id < y.id;
29     return xx < yy;
30 }
31 
32 int main(){
33     Faster;
34     int n;
35     while(cin >> n){
36         for(int i = 0;i < n;i++){
37             cin >> t[i].a >> t[i].b >> t[i].c;
38             t[i].id = i+1;
39         }
40         sort(t,t+n,cmp);
41         for(int i = 0;i < n;i++){
42             if(i == 0)
43                 cout << t[i].id;
44             else
45                 cout << " " << t[i].id;
46         }
47         cout << endl;
48     }
49     return 0;
50 }
View Code

 

以上是关于2018ccpc_hn的主要内容,如果未能解决你的问题,请参考以下文章

Codeigniter 助手重复 HTML 代码片段

关于代码片段的时间复杂度

这些角度电子邮件指令代码片段如何连接

使用 Pygments 检测代码片段的编程语言

有人可以解释以下 R 代码片段吗? [关闭]

有没有办法关闭代码片段中的命名建议?