Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #define MAXN 1000000
- typedef long long ll;
- ll need[MAXN];
- void valuta(int N, int C[], int L[], int P[])
- {
- for(int i=0; i<N; i++) P[i] = 0;
- ll s=0, uranio=0;
- for(int i=0; i<2*N; i++)
- {
- uranio+=(C[i%N]-L[i%N]);
- if(uranio < 0)
- {
- s = i+1;
- uranio = 0;
- }
- }
- if(s >= N) return;
- need[s] = 0;
- P[s] = 1;
- for(int i=1; i<N; i++)
- {
- s = (s-1)%N;
- need[s] = std::max((ll)0, L[s] - C[s] + need[(s+1)%N]);
- if(need[s] == 0) P[s] = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement