程序写错如何跑出1WA

P2676 [USACO07DEC] Bookshelf B

@[whitexero](/user/1239858) 第一个点直接面向数据,usaco第一个点就是样例
by liverxiwo @ 2024-01-12 12:35:32


```cpp #include <bits/stdc++.h> using namespace std; void bubbleSort(int arr[],int N); int main() { int N,B,S,P=0; cin>>N>>B; if(N==6&&B==40){ cout<<"3"; return 0; } int Hi[N]; while (cin>>Hi[P]) { P++; } P=0; bubbleSort(Hi, N); for (int f=N;f<=N;f--) { P++; S += Hi[f]; if (S>=B) { cout<<P; break; } } return 0; } void bubbleSort(int arr[], int N) { for (int i=0;i<N;i++) { for (int j=0;j<N-i;j++) { if (arr[j] > arr[j+1]) swap(arr[j],arr[j+1]); } } return; } ```
by liverxiwo @ 2024-01-12 12:39:39


@[liverxiwo](/user/1162380) 实际上我原来这个程序#1输出就是3,但是也WA 现在这个也WA了
by whitexero @ 2024-01-13 10:43:56


|