Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ull = unsigned long long;
  5. using ll = long long;
  6. using ld = long double;
  7.  
  8. #define re return
  9. #define all(c) (c).begin(),(c).end()
  10. #define sz(c) (int)(c).size()
  11. #define pb push_back
  12. #define forn(i, begin, end) \
  13. for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  14. #define tr(container, it) \
  15. for(auto it = container.begin(); it != container.end(); ++it)
  16. #define present(container, val) (container.find(val) != container.end())
  17. #define cpresent(container, val) (find(all(container),val) != container.end())
  18. #define Matrix(n,m,k) vector<vector<int> >(n, vector<int>(m, k));
  19. #define what_is(x) cout << #x << " is " << x << endl;
  20. #define EPS numeric_limits<double>::epsilon()
  21. #define printVector(v) for (size_t i = 0; i < v.size(); ++i) cout << setw(2) << v[i] << " "; cout << endl;
  22. #define F first
  23. #define S second
  24.  
  25. template<class T> T
  26. abs(T x) { re x > 0 ? x : -x; }
  27.  
  28. typedef long double ld;
  29. typedef pair<int, int> ii;
  30. typedef vector<int> vi;
  31. typedef vector<ii> vii;
  32. typedef vector<string> vs;
  33. typedef vector<vi> vvi;
  34. typedef set<int> si;
  35. typedef map<string, int> msi;
  36. typedef map<int, int> mii;
  37. typedef set<int> si;
  38.  
  39. vi t;
  40. int n, m;
  41.  
  42. int
  43. main() {
  44. ios_base::sync_with_stdio(false);
  45. #ifdef FILE_IO
  46. freopen("input.txt", "r", stdin);
  47. // freopen("output.txt", "w", stdout);
  48. #endif
  49. cin >> n >> m;
  50. t.resize(m);
  51. forn(i,0,m) cin >> t[i];
  52. priority_queue<pair<ll, ll>, vector<ll>, greater<pair<ll, ll>>> q;
  53. forn(i,0,m) {
  54. int queue_size = int(q.size());
  55. if (queue_size < n) {
  56. q.push(pair<ll, ll>(t[i], queue_size));
  57. cout << queue_size << ' ' << 0 << endl;
  58. } else {
  59. auto top = q.top();
  60. cout << top.S << ' ' << top.F << endl;
  61. q.pop();
  62. q.push(pair<ll, ll>(t[i] + top.F, top.S));
  63. }
  64. }
  65. re 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement