Submission #958593

#TimeUsernameProblemLanguageResultExecution timeMemory
958593KasymKArt Exhibition (JOI18_art)C++17
0 / 100
12 ms348 KiB
#include "bits/stdc++.h" using namespace std; #define int long long int n; int ans = INT_MIN; vector<int> a, b, vis; void belle(string s){ int S = 0; int minA = INT_MAX, maxA = INT_MIN; bool bamy = false; for(char &i : s) if(i == '1'){ bamy = true; break; } if(!bamy) return; for(int i = 0; i < n; ++i) if(s[i] == '1'){ S += b[i]; minA = min(minA, a[i]); maxA = max(maxA, a[i]); } ans = max(ans, S - (maxA - minA)); } void f(int x){ if(x == n){ string s; for(int &i : vis) s += (i ? '1' : '0'); belle(s); return; } for(int i = 0; i <= 1; ++i){ vis[x] = i; f(x + 1); } } void solve(){ scanf("%d", &n); a.resize(n); b.resize(n); vis.resize(n); for(int i = 0; i < n; ++i) scanf("%lld %d", &a[i], &b[i]); f(0); printf("%lld\n", ans); } signed main(){ int t = 1; // scanf("%d", &t); while(t--) solve(); return 0; }

Compilation message (stderr)

art.cpp: In function 'void solve()':
art.cpp:46:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   46 |     scanf("%d", &n);
      |            ~^   ~~
      |             |   |
      |             |   long long int*
      |             int*
      |            %lld
art.cpp:51:22: warning: format '%d' expects argument of type 'int*', but argument 3 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
   51 |         scanf("%lld %d", &a[i], &b[i]);
      |                     ~^
      |                      |
      |                      int*
      |                     %lld
art.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
art.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         scanf("%lld %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...