2 solutions
-
0
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef pair<int, int> PII; using ll = long long; using ULL = unsigned long long; const int N = 1e7 + 5; int n, a[N]; inline void solve() { cin >> n; ll sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } cout << *max_element(a,a+n) << endl << *min_element(a,a+n) << endl << sum << endl; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int _ = 1; //int _; cin >> _; while (_--) solve(); return 0; }
-
0
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e5+10; int a[N],sum; int main() { int n;cin>>n; int maxx = -10001,minn = 10001; for(int i = 1;i <= n;i++) { cin>>a[i]; } for(int i = 1;i <= n;i++) { sum += a[i]; maxx = max(maxx,a[i]); minn = min(minn,a[i]); } cout<<maxx<<"\n"<<minn<<"\n"<< sum<<"\n"; return 0; }
- 1
Information
- ID
- 1832
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 4
- Tags
- # Submissions
- 43
- Accepted
- 20
- Uploaded By