Codeforces Round 998 (Div. 3)
2025-01-27 14:32:25
# codeforces
Codeforces Round 998 (Div. 3)
A
md一开始没读懂Fibonacciness 到底是个神马东西。直接遍历
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false) int main() { IOS; int t; cin>>t; while(t--) { int a[10]; for(int i=1;i<=5;i++) { if(i!=3) cin>>a[i]; } int maxn=0,cnt=0; for(int i=1;i<=3;i++) { cnt=0; if(i==1) a[3] = a[1]+a[2]; else if(i==2) a[3] = a[4]-a[2]; else a[3] = a[5]-a[4]; for(int j=1;j<=3;j++) { if(a[j]+a[j+1]==a[j+2]) cnt++; } maxn = max(maxn,cnt); } cout<<maxn<<endl; } return 0; }
|
B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false) const int N = 2002; struct s { int r[N]; int index; } c[N]; bool compare(s a,s b) { return a.r[0]<=b.r[0]; } int main() { IOS; int t; cin>>t; while(t--) { int n,m; cin>>n>>m; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>c[i].r[j]; } c[i].index = i+1; } for(int i=0;i<n;i++) sort(c[i].r,c[i].r+m); sort(c,c+n,compare); int cnt = -1; int flag = 0; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { if(c[j].r[i]>cnt) cnt = c[j].r[i]; else { flag = 1; cout<<-1<<endl; break; } } if(flag) break; } if(!flag) { for(int i=0;i<n;i++) cout<<c[i].index<<' '; cout<<endl; }
} return 0; }
|
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false) const int N = 2e5+5; int a[N]; int main() { IOS; int t; cin>>t; while(t--) { int n,k; cin>>n>>k; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); int i=0,j=n-1; int score = 0; while(i<j) { if(a[i]+a[j]==k) { i++,j--; score++; } else if(a[i]+a[j]<k) i++; else j--; } cout<<score<<endl; } return 0; }
|