fork download
  1. ///
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int n,q,t,k,d;
  6. int Time[105],stmp,cnt;
  7.  
  8. int main()
  9. {
  10. // freopen("nhap.inp", "r", stdin);
  11. cin>>n>>q;
  12. for (int i=1; i <= q; i++)
  13. {
  14. scanf("%d %d %d",&t,&k,&d);
  15. stmp=cnt=0;
  16. for (int j=1; j<=n; j++)
  17. {
  18. if (Time[j]<=t)
  19. {
  20. stmp+=j;
  21. Time[j]=t+d;
  22. cnt++;
  23. if (cnt==k) break;
  24. }
  25. }
  26. if (cnt!=k) printf("-1\n");
  27. else printf("%d\n",stmp);
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty