1 solutions

  • 0
    @ 2025-11-5 20:07:29

    C :

    #include <stdio.h>
    int main() {
    	int c,x,i,j,n,t=1,a[12],sum;
    	j=0,sum=0,t=1;
    	for(i=1; i<=12; i++) {
    		sum += 300;
    		scanf("%d",&x);
    		sum -= x;
    		if(sum<0) {
    			a[t]=-i;
    			t++;
    		}
    		if(sum>=100) {
    			n=sum/100;
    			sum = sum - n*100;
    			j+=n;
    		}
    	}
    	if(t>1) {
    		printf("%d\n",a[1]);
    	} else {
    		sum = sum + (j*120);
    		printf("%d\n",sum);
    	}
    	return 0;
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
    	bool flag=false;
    	int x=0,r=0,s=0,a=0;
    	for(int i=1;i<=12;i++)
    	{
    		r+=300;
    		cin>>a;
    		if(a>r)
    		{
    			flag=true;
    			if(x==0)x=i;
    		}
    		r-=a;
    		s+=(r/100)*100;
    		r%=100;
    	}
    	if(flag==true)
    	{
    		cout<<'-'<<x<<endl;
    	}
    	else
    	{
    		s*=1.2;
    		x=r+s;
    		cout<<x+1<<endl;
    	}
    	return 0;
    }
    

    Pascal :

    var a:array[1..12]of integer;
        I,total,p:integer;
    begin
      {assign(input,'save.in');
      reset(input);
      assign(output, 'save.out');
      rewrite(output);}
      
      total:=0;
      for i:=1 to 12 do
    readln(a[i]);
      for i:=1 to 12 do
    begin
      total:=total+(300-a[i]);
      if total<0 then
        begin
          write('-',i);
           halt;
        end;
      if total>=100 then
        begin
          p:=p+total div 100;
          total:=total mod 100;
         end;
       end;
    writeln(p*120+total);
        {close(input);
        close(output);}
      end.
    
    • 1

    Information

    ID
    20032
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By