版本比较
3/27 蒋
正文
增加 23 行删除 23 行
13 行未改动1415161718192021222324252627282913 行未改动434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888917 行未改动1071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401418 行未改动13 行未改动int main(){cin >> n;for(int i = n; i >= 1; i--){dq.push_front(i);dq.push_front(dq.back());dq.pop_back();}while(dq.size() > 0){cout << dq.front() << " ";dq.pop_front();13 行未改动using namespace std;int n, a[105];queue<int> q, q2;int main(){cin >> n;for(int i = 1; i <= n; i++){cin >> a[i];q.push(a[i]);}int maxi = -1e9;for(int i = 1; i <= n; i++){q.push(q.front());q.pop();q2 = q;int cnt = 1, ans = 0;while(cnt <= n && q2.empty() == 0){if(cnt == q2.front()){cnt = 1;ans += q2.front();q2.pop();continue;}q2.push(q2.front());q2.pop();cnt++;}maxi = max(maxi, ans);}cout << maxi;return 0;}```17 行未改动signed main(){cin >> n >> p;for(int i = 1; i <= n; i++){cin >> a[i];}int sum = 0;for(int i = 1; i <= n; i++){sum += a[i];pq.push(-a[i]);while(sum + pq.top() >= p){sum -= -pq.top();pq.pop();}if(sum >= p){cout << pq.size() << " ";}else{cout << -1 << " ";}}return 0;}```# U504636 拖板车8 行未改动13 行未改动1415161718192021222324252627282913 行未改动434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888917 行未改动1071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401418 行未改动13 行未改动int main(){cin >> n;for(int i = n; i >= 1; i--){dq.push_front(i);dq.push_front(dq.back());dq.pop_back();}while(dq.size() > 0){cout << dq.front() << " ";dq.pop_front();13 行未改动using namespace std;int n, a[105];queue<int> q, q2;int main(){cin >> n;for(int i = 1; i <= n; i++){cin >> a[i];q.push(a[i]);}int maxi = -1e9;for(int i = 1; i <= n; i++){q.push(q.front());q.pop();q2 = q;int cnt = 1, ans = 0;while(cnt <= n && q2.empty() == 0){if(cnt == q2.front()){cnt = 1;ans += q2.front();q2.pop();continue;}q2.push(q2.front());q2.pop();cnt++;}maxi = max(maxi, ans);}cout << maxi;return 0;}```17 行未改动signed main(){cin >> n >> p;for(int i = 1; i <= n; i++){cin >> a[i];}int sum = 0;for(int i = 1; i <= n; i++){sum += a[i];pq.push(-a[i]);while(sum + pq.top() >= p){sum -= -pq.top();pq.pop();}if(sum >= p){cout << pq.size() << " ";}else{cout << -1 << " ";}}return 0;}```# U504636 拖板车8 行未改动