PikMike

Untitled

Mar 13th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define pf push_front
  5. #define mp make_pair
  6. #define sz size
  7. #define ll long long
  8. #define ld long double
  9. #define fs first
  10. #define sc second
  11. #define forn(i, f, t) for(int i = f; i < t; i++)
  12. #define all(x) (x).begin(), (x).end()
  13. #define ins insert
  14.  
  15. const int INF = 2147483647;
  16. const int MOD = 1000000007;
  17. const ll INF64 = 9223372036854775807;
  18. const ld EPS = 1e-7;
  19.  
  20. using namespace std;
  21.  
  22.  
  23. int main(){
  24.     int n, m, s, d;
  25.     scanf("%d%d%d%d", &n, &m, &s, &d);
  26.     int a[n];
  27.     forn(i, 0, n) scanf("%d", a + i);
  28.     sort(a, a + n);
  29.     int curl = a[0], curr = a[0] + 1;
  30.     vector<pair<int, int> > b;
  31.     forn(i, 1, n){
  32.         if (a[i] - curr > s){
  33.             b.pb(mp(curl, curr));
  34.             curl = a[i];
  35.         }
  36.         curr = a[i] + 1;
  37.     }
  38.     b.pb(mp(curl, curr));
  39.     int k = b.sz();
  40.     // forn(i, 0, k) printf("[%d, %d] ", b[i].fs, b[i].sc); printf("\n");
  41.     vector<int> q, p;
  42.     bool fl = 1;
  43.     forn(i, 0, k){
  44.         if (b[i].fs - (i ? b[i - 1].sc : 0) - 1 < s) fl = 0;
  45.         q.pb(b[i].fs - (i ? b[i - 1].sc : 0) - 1);
  46.         if (b[i].sc - b[i].fs + 1 > d) fl = 0;
  47.         p.pb(b[i].sc - b[i].fs + 1);
  48.     }
  49.     if (!fl) printf("IMPOSSIBLE\n");
  50.     else{
  51.         if (b[k - 1].sc != m) q.pb(m - b[k - 1].sc);
  52.         forn(i, 0, p.sz()) printf("RUN %d\nJUMP %d\n", q[i], p[i]);
  53.         if (p.sz() < q.sz()) printf("RUN %d\n", q[q.sz() - 1]);
  54.     }
  55.     return 0;
  56. }
Add Comment
Please, Sign In to add comment