Codeforces Round #443 (Div. 2), problem: (D) Teams Formation Solution In C/C++

By |2017-11-08T09:26:00+00:00November 8th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <stdio.h> struct node { __int64 ans,num; }s[101000]; int main() { int n,k,m; while(~scanf("%d%d%d",&n,&k,&m)) { scanf("%I64d",&s[0].num); s[0].ans=1; int len=1; for(int i=1;i<n;i++) { int x; scanf("%d",&x); if(x==s[len-1].num) { s[len-1].ans++; if(s[len-1].ans==k) { s[len-1].ans=0; len--; } } else { s[len].num=x; s[len].ans=1; len++; } } int l=0,r=len-1; __int64 [...]