Task: | Increasing Array |
Sender: | lnan95 |
Submission time: | 2020-09-26 13:07:33 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.02 s | details |
#5 | ACCEPTED | 0.02 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ~~~~~^~~~~~~~~~ input/code.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &curValue); ~~~~~^~~~~~~~~~~~~~~~~~~
Code
#include <cstdio> #include <vector> using namespace std; int n; int main() { scanf("%d", &n); long long int curValue = 0, lastValue = 0, ops = 0; for (int i=0; i<n; i++) { scanf("%lld", &curValue); if (curValue < lastValue) { ops += lastValue - curValue; } else lastValue = curValue; } printf("%lld", ops); }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10 1 1 1 1 1 1 1 1 1 1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
10 1000000000 1 1 1 1 1 1 1 1 1 |
correct output |
---|
8999999991 |
user output |
---|
8999999991 |
Test 3
Verdict: ACCEPTED
input |
---|
10 6 10 4 10 2 8 9 2 7 7 |
correct output |
---|
31 |
user output |
---|
31 |
Test 4
Verdict: ACCEPTED
input |
---|
200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
200000 1000000000 1 1 1 1 1 1 1 1 1 1... |
correct output |
---|
199998999800001 |
user output |
---|
199998999800001 |
Test 6
Verdict: ACCEPTED
input |
---|
200000 763977854 530688450 486447012 ... |
correct output |
---|
100126194120455 |
user output |
---|
100126194120455 |
Test 7
Verdict: ACCEPTED
input |
---|
1 329873232 |
correct output |
---|
0 |
user output |
---|
0 |