Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define pf push_front
- #define mp make_pair
- #define sz size
- #define ll long long
- #define ld long double
- #define fs first
- #define sc second
- #define forn(i, f, t) for(int i = f; i < t; i++)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- const int INF = 2147483647;
- const int MOD = 1000000007;
- const ll INF64 = 9223372036854775807;
- const ld EPS = 1e-7;
- using namespace std;
- int main(){
- int n, m, s, d;
- scanf("%d%d%d%d", &n, &m, &s, &d);
- int a[n];
- forn(i, 0, n) scanf("%d", a + i);
- sort(a, a + n);
- int curl = a[0], curr = a[0] + 1;
- vector<pair<int, int> > b;
- forn(i, 1, n){
- if (a[i] - curr > s){
- b.pb(mp(curl, curr));
- curl = a[i];
- }
- curr = a[i] + 1;
- }
- b.pb(mp(curl, curr));
- int k = b.sz();
- // forn(i, 0, k) printf("[%d, %d] ", b[i].fs, b[i].sc); printf("\n");
- vector<int> q, p;
- bool fl = 1;
- forn(i, 0, k){
- if (b[i].fs - (i ? b[i - 1].sc : 0) - 1 < s) fl = 0;
- q.pb(b[i].fs - (i ? b[i - 1].sc : 0) - 1);
- if (b[i].sc - b[i].fs + 1 > d) fl = 0;
- p.pb(b[i].sc - b[i].fs + 1);
- }
- if (!fl) printf("IMPOSSIBLE\n");
- else{
- if (b[k - 1].sc != m) q.pb(m - b[k - 1].sc);
- forn(i, 0, p.sz()) printf("RUN %d\nJUMP %d\n", q[i], p[i]);
- if (p.sz() < q.sz()) printf("RUN %d\n", q[q.sz() - 1]);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment