只有40分,思路就是加上第一个数和其他数的绝对值,subtask1和4过了,其余全红,求dalao纠错
代码:
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
int temp,ans=0;
cin >> temp;
ans+=temp;
for(int i=2;i<=n;i++){
cin >> temp;
if(temp<0)ans-=temp;
else ans+=temp;
}
cout << ans << endl;
return 0;
}