2 solutions

  • 1
    @ 2026-10-7 9:11:07
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        long long t=n;
        int maxv;
        for(int i=1;i<=n;i++)
        {
            long long x;
            cin>>x;
            long long t=x;
            int s=0;
            while(t)
            {
                int ge=t%10;
                s=s+ge;
                t=t/10;
            }
            if(i==1||s>maxv)
            {
                maxv=s;
            }
        }
        cout<<maxv;
    	return 0; 
    }
    
    • 0
      @ 2026-8-4 19:04:37

      #include<bits/stdc++.h> using namespace std; int main() { long long a; cin>>a; long long sum=0; for(int i=1;i<=a;i++) { long long b; cin>>b; long long s=0; long long t=b; while(t) { s+=t%10; t=t/10; } if(s>sum) { sum=s; } } cout<<sum<<endl; return 0; }

      • 1

      Information

      ID
      2212
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      7
      Tags
      # Submissions
      118
      Accepted
      27
      Uploaded By