打扑克

#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<int> vec;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        vec.push_back(x);
    }
    int cnt = 0;
    deque<int> dq;
    while (!vec.empty())
    {
        int t = vec.back();
        vec.pop_back();
        dq.push_front(t);
        for (int i = 0; i < 2; i++)
        {
            dq.push_front(dq.back());
            dq.pop_back();
        }
        cnt++;
    }
    
    for (int i = 0; i < dq.size(); i++) cout << dq[i] << " ";
    cout << endl;

}

送外卖



#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> vec;
    while (n--)
    {
        int x;
        cin >> x;
        vec.push_back(x);
    }
    vector<int> vec2(vec.size(), t);
    for (int i = 1; i < vec.size(); i++)
    {
        vec2[i] = vec2[i - 1] + t;
    } 
    int ans = 0;
    int cnt = 0;
    sort(vec.begin(), vec.end());
    for (int i = 0; i < vec.size(); i++)
    {
        if (vec[i] >= vec2[cnt])
        {
            cnt++;
        }
        else ans++;
    }
    cout << ans << endl;
}

Q.E.D.