2 solutions

  • 1
    @ 2026-1-25 21:35:47
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b[100000]={};
        cin>>a;
        for(int i=0;i<a;i++)
        {
            string c;cin>>c;int s=0;
            for(int j=0;j<c.length();j++)s+=c[j]-48;
            b[i]=s;
        }
        sort(b,b+a);
        cout<<b[a-1];
    }
    
    • -1
      @ 2025-11-27 11:55:04

      C++ :

      #include <bits/stdc++.h>
      using namespace std;
      #define ll long long
      int main() {
          int n;
          cin >> n;
          int x = 0;
          for (int i = 0; i < n; i++) {
              int smu = 0;
              ll tmp;
              cin >> tmp;
              while (tmp > 0) {
                  smu += tmp % 10;
                  tmp /= 10;
              }
              x = max(x, smu);
          }
          cout << x << endl;
          return 0;
      }
      
      • 1

      Information

      ID
      31
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      6
      Tags
      # Submissions
      28
      Accepted
      10
      Uploaded By