Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("roata.in");
- ofstream fout("roata.out");
- struct cabina{
- int de;bool oc = false;
- }a[10001];
- bool ok = true;
- cabina cab[361];
- int n,p,v[100001],r=1,s=0;
- int main()
- {
- fin >> n >> p;
- for(int i = 1;i<=p;i++){
- fin >> v[i];
- if(cab[n].oc == false){
- cab[i].de = i;
- cab[i].oc = true;
- r++;
- }
- s+= v[i];
- }
- fout << s << endl;
- while(ok){
- for(int i = 1;i<=n;i++){
- v[cab[i].de]--;
- if(v[cab[i].de] == 0){
- fout << cab[i].de << " ";
- cab[i].de = r;
- r++;
- if(r-n > p){
- fout << endl << i;
- ok = false;
- break;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement