NC253174. Homework
描述
输入描述
The first line contains one integer .
The second line contains integers .
The third line contains integers .
输出描述
Print one integer representing the minimum number of seconds required to finish all homework.
示例1
输入:
5 800 1500 1000 2000 3000 50 40 60 80 100
输出:
3230
说明:
Finish the fifth homework first, and copy the fifth homework to others.C++(clang++ 11.0.1) 解法, 执行用时: 75ms, 内存消耗: 2072K, 提交时间: 2023-06-08 00:24:05
#include<bits/stdc++.h> using namespace std; #define int long long #define N 1000010 int n,ans,sum,a[N],b[N]; signed main(){ cin>>n; for (int i=1;i<=n;i++) cin>>a[i],ans=max(ans,a[i]); for (int i=1;i<=n;i++) cin>>b[i],ans+=b[i],sum=max(sum,b[i]); cout<<ans-sum; }
C++(g++ 7.5.0) 解法, 执行用时: 69ms, 内存消耗: 440K, 提交时间: 2023-06-22 01:29:36
#include<iostream> using namespace std; long n,cnt,ans,a; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a; cnt=max(cnt,a); } for(int i=0;i<n;i++){ cin>>a; cnt+=a; ans=max(ans,a); } cout<<cnt-ans; return 0; }
Python3 解法, 执行用时: 155ms, 内存消耗: 20168K, 提交时间: 2023-06-03 19:51:15
n=int(input()) q=list(map(int,input().split())) w=list(map(int,input().split())) a=max(q) for i in range(len(w)): a+=w[i] print(a-max(w))