2022.4.10周学习总结
一、本周学习进度
1.java开始写项目了,数据库连接也建好了。
2.邮箱发送的功能已经写好了
3.登录功能写好了
4.注册功能还差一点点就写好了
二、本周打比赛及补题情况
1.cf781div2(比赛的时候只写了两道题,补题的时候补了一道)
C题当时有思路但是wa了,没写出来,赛后看别人题解,学了一手别人的二分。然后补了出来
代码实现
1 #include <iostream>
2 #include <queue>
3 #include <vector>
4 #include <cstring>
5 #include <string>
6 #include <map>
7 #include <cmath>
8 #include <algorithm>
9 #include <set>
10 #include <stack>
11 #include <cstdio>
12 #include <climits>
13 #define PII pair<int,int>
14 #define rep(i,z,n) for(int i = z;i <= n; i++)
15 #define per(i,n,z) for(int i = n;i >= z; i--)
16 #define ll long long
17 #define db double
18 #define vi vector<int>
19 #define debug(x) cerr << "!!!" << x << endl;
20 using namespace std;//
21 inline ll read()
22 {
23 ll s,r;
24 r = 1;
25 s = 0;
26 char ch = getchar();
27 while(ch < '0' || ch > '9'){
28 if(ch == '-')
29 r = -1;
30 ch = getchar();
31 }
32 while(ch >= '0' && ch <= '9'){
33 s = (s << 1) + (s << 3) + (ch ^ 48);
34 ch = getchar();
35 }
36 return s * r;
37 }
38 inline void write(ll x)
39 {
40 if(x < 0) putchar('-'),x = -x;
41 if(x > 9) write(x / 10);
42 putchar(x % 10 + '0');
43 }
44 int a[200010];
45 int fa[200010];
46 bool vis[200010];
47 bool check(int val,vector <int> &tmp)
48 {
49 int cnt = 0;
50 for(int i = 0,len = tmp.size();i < len;i++){
51 cnt++;
52 cnt += max(0,tmp[i] - (val - i));
53 }
54 // cout << cnt << endl;
55 return cnt <= val;
56 }
57 bool cmp(int p,int k)
58 {
59 return p > k;
60 }
61 int main()
62 {
63 int t;
64 cin >> t;
65 while(t--){
66 int n;
67 memset(fa,0,sizeof(fa));
68 memset(vis,0,sizeof(vis));
69 vector <int> tmp;
70 //fa[0]++;
71 tmp.push_back(1);
72 scanf("%d",&n);
73 rep(i,1,n - 1) {
74 cin >> a[i];
75 fa[a[i]]++;
76 }
77 rep(i,0,n) if(fa[i]) tmp.push_back(fa[i]);
78 sort(tmp.begin(),tmp.end(),cmp);
79 int l,r;
80 l = 1;
81 r = n;
82 int ans = INT_MAX;
83 while(l <= r){
84 int m = (l + r) >> 1;
85 if(check(m,tmp)){
86 ans = min(ans,m);
87 r = m - 1;
88 }
89 else
90 l = m + 1;
91 }
92 cout << ans << endl;
93 }
94 return 0;
95 }
2.cfedu126(比赛的时候只写了两道题,补题的时候补了一道)
感觉状态有点拉跨,打比赛的时候有点累。思路也很死。
补了一下C题,又是一个二分,还是不会。学了一手别人的二分,看了半天才看懂别人的代码。
1 #include <iostream>
2 #include <queue>
3 #include <vector>
4 #include <cstring>
5 #include <string>
6 #include <map>
7 #include <cmath>
8 #include <algorithm>
9 #include <set>
10 #include <stack>
11 #include <cstdio>
12 #include <climits>
13 #define PII pair<int,int>
14 #define rep(i,z,n) for(int i = z;i <= n; i++)
15 #define per(i,n,z) for(int i = n;i >= z; i--)
16 #define ll long long
17 #define db double
18 #define vi vector<int>
19 #define debug(x) cerr << "!!!" << x << endl;
20 using namespace std;
21 inline ll read()
22 {
23 ll s,r;
24 r = 1;
25 s = 0;
26 char ch = getchar();
27 while(ch < '0' || ch > '9'){
28 if(ch == '-')
29 r = -1;
30 ch = getchar();
31 }
32 while(ch >= '0' && ch <= '9'){
33 s = (s << 1) + (s << 3) + (ch ^ 48);
34 ch = getchar();
35 }
36 return s * r;
37 }
38 inline void write(ll x)
39 {
40 if(x < 0) putchar('-'),x = -x;
41 if(x > 9) write(x / 10);
42 putchar(x % 10 + '0');
43 }
44 bool cmp(int p,int k)
45 {
46 return p > k;
47 }
48 ll a[300010];
49 int n;
50 ll ans;
51 ll check(int val)
52 {
53 ll c1 = 0;
54 ll c2 = 0;
55 rep(i,1,n) {
56 c1 += (val - a[i]) % 2;
57 c2 += (val - a[i]) / 2;
58 }
59 ll c = 0;
60 if(c2 >= c1 + 2)
61 c = (c2 - c1 - 2) / 3 + 1;
62 return max((c1 + 2 * c) * 2 - 1,(c2 - c) * 2);
63 }
64 int main()
65 {
66 int t;
67 ios::sync_with_stdio(false);
68 cin >> t;
69 while(t--){
70 cin >> n;
71 ll mk = -1;
72 ans = 1e18;
73 rep(i,1,n) {
74 cin >> a[i];
75 mk = max(mk,a[i]);
76 }
77 rep(i,0,1) ans = min(ans,check(mk + i));
78 cout << ans << endl;
79 }
80 return 0;
81 }
三、下周学习计划
1.把项目的功能实现更加完整
2.把项目的结构弄的更加规划
3.学一下mvc
4.刷一些题备战天梯
四、本周总结
这一周的状态很拉跨,打cf打的也不好,测试也测试的不好,心态上有点炸裂,每天晚上都在跑步放松,java的项目也要开始往上赶了。加油把~~~QAQ
本文来自博客园,作者:{scanner},转载请注明原文链接:{https://home.cnblogs.com/u/scannerkk/}