Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ull = unsigned long long;
- using ll = long long;
- using ld = long double;
- #define re return
- #define all(c) (c).begin(),(c).end()
- #define sz(c) (int)(c).size()
- #define pb push_back
- #define forn(i, begin, end) \
- for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
- #define tr(container, it) \
- for(auto it = container.begin(); it != container.end(); ++it)
- #define present(container, val) (container.find(val) != container.end())
- #define cpresent(container, val) (find(all(container),val) != container.end())
- #define Matrix(n,m,k) vector<vector<int> >(n, vector<int>(m, k));
- #define what_is(x) cout << #x << " is " << x << endl;
- #define EPS numeric_limits<double>::epsilon()
- #define printVector(v) for (size_t i = 0; i < v.size(); ++i) cout << setw(2) << v[i] << " "; cout << endl;
- #define F first
- #define S second
- template<class T> T
- abs(T x) { re x > 0 ? x : -x; }
- typedef long double ld;
- typedef pair<int, int> ii;
- typedef vector<int> vi;
- typedef vector<ii> vii;
- typedef vector<string> vs;
- typedef vector<vi> vvi;
- typedef set<int> si;
- typedef map<string, int> msi;
- typedef map<int, int> mii;
- typedef set<int> si;
- vi t;
- int n, m;
- int
- main() {
- ios_base::sync_with_stdio(false);
- #ifdef FILE_IO
- freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- #endif
- cin >> n >> m;
- t.resize(m);
- forn(i,0,m) cin >> t[i];
- priority_queue<pair<ll, ll>, vector<ll>, greater<pair<ll, ll>>> q;
- forn(i,0,m) {
- int queue_size = int(q.size());
- if (queue_size < n) {
- q.push(pair<ll, ll>(t[i], queue_size));
- cout << queue_size << ' ' << 0 << endl;
- } else {
- auto top = q.top();
- cout << top.S << ' ' << top.F << endl;
- q.pop();
- q.push(pair<ll, ll>(t[i] + top.F, top.S));
- }
- }
- re 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement