#include<bits/stdc++.h>
using namespace std;
int main (){
int n;
cin>>n;
int t=0,tt=0;
vector<int>a;
vector<int>b;
vector<int>c;
vector<int>d;
for(int i=0;i<n;++i){
int temp;
cin>>temp;
a.push_back(temp);
}
for(int i=0;i<n;++i){
int temp1;
cin>>temp1;
b.push_back(temp1);
}
for(int i=0;i<n;++i){
if(a[i]>b[i]){
c.push_back(i+1);
t++;
}
else{
d.push_back(i+1);
tt++;
}
}
if(t==0){
cout<<"-1";
}
else{
for(int i=0;i<t;++i){
cout<<c[i]<<" ";
}
}
cout<<endl;
if(tt==0){
cout<<"-1";
}
else{
for(int i=0;i<tt;++i){
cout<<d[i]<<" ";
}
}
}
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> scores(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> scores[i][j];
}
}
int best_progress = -1;
int worst_regret = -1;
int best_student = 0;
int worst_student = 0;
for (int i = 0; i < n; i++) {
int progress = 0;
int regret = 0;
for (int j = 1; j < m; j++) {
if (scores[i][j] > scores[i][j - 1]) {
progress += scores[i][j] - scores[i][j - 1];
} else {
regret += scores[i][j - 1] - scores[i][j];
}
}
if (progress > best_progress) {
best_progress = progress;
best_student = i + 1;
}
if (regret > worst_regret) {
worst_regret = regret;
worst_student = i + 1;
}
}
cout << best_student << endl;
cout << worst_student << endl;
return 0;
}
#include <iostream>
using namespace std;
int a[999]={};
// 遞迴函數,模擬染色的過程
void paintFence(int n, int day, int start) {
if (n == 1) {
// 如果柵欄長度為 1,則只需要塗上當天的顏色
switch (day) {
case 1: cout << "R"; break;
case 2: cout << "O"; break;
case 3: cout << "Y"; break;
case 4: cout << "G"; break;
case 5: cout << "B"; break;
case 6: cout << "I"; break;
case 7: cout << "V"; break;
}
return;
}
int third = n / 3; // 計算三等分的大小
if (n % 3 == 0) {
for (int i = start + third; i < start + 2*third; i++) {
a[i-1]=(day + 1) % 7;
}
// 如果能夠完全三等分,則塗中間那一段
paintFence(third, (day + 1) % 7 + 1, start);
paintFence(third, (day + 2) % 7 + 1, start + 2 * third);
}
// 如果無法完全三等分,則直接塗整段
}
int main() {
int n, day;
cin >> n >> day;
paintFence(n, day,);
for(int i=0;i<n;++i){
switch (a[i]) {
case 1: cout << "R"; break;
case 2: cout << "O"; break;
case 3: cout << "Y"; break;
case 4: cout << "G"; break;
case 5: cout << "B"; break;
case 6: cout << "I"; break;
case 7: cout << "V"; break;
}
}
}
cout << endl;
return 0;
}
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up