Submission #384661

#TimeUsernameProblemLanguageResultExecution timeMemory
384661zoooma13Divide and conquer (IZhO14_divide)C++14
48 / 100
1086 ms1900 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); vector <array<int ,3>> a(n); for(auto&x : a) scanf("%d%d%d",&x[0],&x[1],&x[2]); int64_t ans = 0; for(int i=0; i<n; i++){ int64_t gold = 0 ,energy = 0; for(int j=i; j<n; j++){ gold += a[j][1]; energy += a[j][2]; if(energy >= a[j][0]-a[i][0]) ans = max(ans ,gold); } } printf("%lld\n",ans); }

Compilation message (stderr)

divide.cpp: In function 'int main()':
divide.cpp:21:16: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int64_t' {aka 'long int'} [-Wformat=]
   21 |     printf("%lld\n",ans);
      |             ~~~^    ~~~
      |                |    |
      |                |    int64_t {aka long int}
      |                long long int
      |             %ld
divide.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
divide.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%d%d%d",&x[0],&x[1],&x[2]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...