您的答案為: Number: 12 6 13 7 14 0 正確答案為: Number: 12 6 13 7 0 14
您的答案為: Number: 8989 127 7878 129 140 0 86 117 77777 118 123114 120 99995999 122 456444 123 979 124 1 125 正確答案為: Number: 8989 127 7878 129 140 1 86 117 77777 118 123114 120 99995999 122 456444 123 979 124 0 125
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<pair<int, int>> z(n);
int boy, time;
while (cin >> boy >> time) {
for (int i = 0; i < n; i++) {
if (z[i].second != 0) {
z[i].second--;
}
if(z[i].second==0){
z[i].first=0;
}
}
bool v = false;
for (int i = 0; i < n; i += 2) {
if (z[i].second == 0) {
z[i] = make_pair(boy, time);
cout << "Number:";
for (pair<int, int> q : z) {
cout << ' ' << q.first;
}
cout << "\n Time:";
for (pair<int, int> q : z) {
cout << ' ' << q.second;
}
cout << "\n";
v = true;
break;
}
}
if (v) {
continue;
}
for (int i = 1; i < n; i += 2) {
if (z[i].second == 0) {
z[i] = make_pair(boy, time);
cout << "Number:";
for (pair<int, int> q : z) {
cout << ' ' << q.first;
}
cout << "\n Time:";
for (pair<int, int> q : z) {
cout << ' ' << q.second;
}
cout << "\n";
v = true;
break;
}
}
if (v) {
continue;
}
cout << " Not enough\nNumber:";
for (pair<int, int> q : z) {
cout << ' ' << q.first;
}
cout << "\n Time:";
for (pair<int, int> q : z) {
cout << ' ' << q.second;
}
cout << "\n";
}
}
#3: 30% WA (line:25)
您的答案為: Number: 12 6 13 7 14 0 正確答案為: Number: 12 6 13 7 0 14#4: 40% WA (line:104)
您的答案為: Number: 8989 127 7878 129 140 0 86 117 77777 118 123114 120 99995999 122 456444 123 979 124 1 125 正確答案為: Number: 8989 127 7878 129 140 1 86 117 77777 118 123114 120 99995999 122 456444 123 979 124 0 125
你先檢查陣列編號偶數項再檢查陣列編號奇數項會忽略題目的間隔原則,如下
Array : 0 1 2 3 4 5 6 7
Number: 0 1 2 3 0 0 0 5
Time: 3 3 3 3 0 0 0 3
你的程式位可能會因為看到陣列編號為4的那格是空的,就把人排進去了(因為它的陣列編號是偶數的),但其實依照題意,那人應該站在陣列編號5的位置才對,必須符合間隔原則
我也是錯這裡