Submission #211717

#TimeUsernameProblemLanguageResultExecution timeMemory
211717goodboyPotatoes and fertilizers (LMIO19_bulves)C++14
0 / 100
18 ms16256 KiB
#include <bits/stdc++.h> using namespace std; int fertiliser[1000005],potatoes[1000005]; int main() { int n , a , b; scanf("%d",&n); int pot = 0, fert = 0; for (int i = 1; i <= n; i++) { scanf("%d%d",&a,&b); for (int j = 1; j <= a; j++) { fert++; fertiliser[fert] = i; } for (int j = 1; j <= b; j++) { pot++; potatoes[pot] = i; } } long long ans = 0; for(int i = 1; i <= pot; i++)ans += abs(fertiliser[i] - potatoes[i]); printf("%lld\n",ans); }

Compilation message (stderr)

bulves.cpp: In function 'int main()':
bulves.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bulves.cpp:11:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d%d",&a,&b);
      ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...