2022.4.10周學習總結
阿新 • • 發佈:2022-04-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