#include <iostream>
#include <vector>
using namespace std;
long long n;
long long s;
int main(){
cin>>n;
vector<long long>a(n);
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(long long i=1;i<=n;i=i+2){
s+=a[i]-a[i+1];
}
cout<<s;
return 0;
}
When I run the above code in Code::Blocks, it runs normally.
But when I paste to judge, it says:
Compiled Successfully. memory: 3524 time: 0.36 exit code: 134
and it has no output.
I tried to run on Ideone and online GDB, but same result.
How does this work?
for(long long i=1
- the first element is at index0
, not1
. Why do you start your loop at index1
?But when I paste to judge, it says
" - Don't waste your time on online judges and/or competitive coding websites. You are just wasting your time for no gain.