제출 #784629

#제출 시각아이디문제언어결과실행 시간메모리
784629AlfraganusArt Exhibition (JOI18_art)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> using namespace std; // using namespace __gnu_pbds; // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; #define int long long #define str string #define fastio ios::sync_with_stdio(0), cin.tie(0); #define fs first #define ss second #define endl '\n' #define all(x) (x).begin(), (x).end() #define len(x) x.size() #define print(a) \ for (auto &x : a) \ cout << x << " "; \ cout << endl; #define printmp(a) \ for (auto &x : a) \ cout << x.fs << " " << x.ss << endl; const int mod = 1e9 + 7; const long long INF = LLONG_MAX; const long long NEG_INF = LLONG_MIN; void solve() { int n; cin>>n; vector<pair<int, int>> a(n); for(int i = 0; i < n; i ++)cin>>a[i].fs >> a[i].ss; sort(all(a), greater<pair<int, int>> ()); vector<pair<int, int>> b; int i = 0; while(i < n){ int s = a[i].ss; while(i < n and a[i].fs == a[i + 1].fs)s += a[++ i].ss; b.push_back({a[i].fs, s}); i ++; } b.push_back({b.back().fs, 0}); reverse(all(b)); int ans = 0, sum = 0; for(int i = 1; i < b.size(); i ++){ sum = max(0ll, sum + b[i].ss + (b[i - 1].fs - b[i].fs)); ans = max(ans, sum); } cout<<ans; } signed main() { fastio int t = 1; // cin >> t; while (t--) { solve(); cout << endl; } }

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

art.cpp: In function 'void solve()':
art.cpp:48:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i = 1; i < b.size(); 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...