제출 #581998

#제출 시각아이디문제언어결과실행 시간메모리
581998hibikiArt Exhibition (JOI18_art)C++11
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int n; long long a[500005],b[500005],ans = 0, sum = 0, mi = 0; vector<int> v; int main() { scanf("%d",&n); for(int i = 0; i < n; i++) { scanf("%d %d",&a[i],&b[i]); v.pb(i); } sort(v.begin(),v.end(), [&](const int x,const int y) { return a[x] < a[y]; }); int l = 0; for(int r = 0; r < n; r++) { sum += b[v[r]]; mi = a[v[r]] - a[v[l]]; while(sum - mi < 0) { sum -= b[v[l]]; l++; mi = a[v[r]] - a[v[l]]; } ans = max(ans, sum - mi); } printf("%lld\n",ans); }

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:15:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   15 |         scanf("%d %d",&a[i],&b[i]);
      |                ~^     ~~~~~
      |                 |     |
      |                 int*  long long int*
      |                %lld
art.cpp:15:20: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   15 |         scanf("%d %d",&a[i],&b[i]);
      |                   ~^        ~~~~~
      |                    |        |
      |                    int*     long long int*
      |                   %lld
art.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
art.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d",&a[i],&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...