Submission #751810

#TimeUsernameProblemLanguageResultExecution timeMemory
751810vjudge1Art Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #define LL long long using namespace std; int main() { LL n; scanf("%lld",&n); pair<LL,LL>arr[n+5]; for(LL a=1;a<=n;a++) { LL x,y; scanf("%lld %lld",&x,&y); arr[a]=make_pair(x,y); } sort(arr+1,arr+n+1); bool tama=1; LL awal,tot=0; LL maks=0; for(LL a=1;a<=n;a++) { if(a==1) { tot+=arr[a].second; maks=max(maks,tot); awal=a; } else { tot+=arr[a].second; if(tot-abs(arr[a].first-arr[awal].first)<0) { tot=arr[a].second; awal=a; maks=max(tot,maks); } maks=max(tot-(arr[a].first-arr[awal].first),maks); } // printf("%lld\n",maks); } cout<<tot<<endl; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:16:7: warning: unused variable 'tama' [-Wunused-variable]
   16 |  bool tama=1;
      |       ^~~~
art.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
art.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lld %lld",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...