Submission #68432

#TimeUsernameProblemLanguageResultExecution timeMemory
68432MrTEKDivide and conquer (IZhO14_divide)C++14
0 / 100
6 ms1276 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define len(a) (int)a.size() #define fi first #define sc second #define cout maltahsin #define left ind + ind #define right ind + ind + 1 #define mid (l + r) / 2 #define d1(w) cerr<<#w<<":"<<w<<endl; #define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl; #define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl; #define FAST_IO ios_base::sync_with_stdio(false); #define endl '\n' const int maxn = 620; const long long LINF = 1e18; const int LOG = 31; const int INF = 1e9 + 5; const int N = 1e5 + 5; const int M = 1e5 + 5; const int SQ = 350; const int MOD = 998244353; typedef pair <int,int> pii; map <long long,int> mpx; int n,x[N],g[N],d[N]; long long ans,pred[N],preg[N]; int main() { scanf("%d",&n); for (int i = 1 ; i <= n ; i++) { scanf("%d %d %d",&x[i],&g[i],&d[i]); pred[i] = pred[i - 1] + d[i]; preg[i] = preg[i - 1] + g[i]; } for (int i = 1 ; i <= n ; i++) { int lst = mpx[pred[i] - x[i]]; ans = max(ans,1ll * g[i]); if (lst) ans = max(preg[i] - preg[lst - 1],ans); if (!mpx[pred[i - 1] - x[i]]) mpx[pred[i - 1] - x[i]] = i; } printf("%lld\n",ans); }

Compilation message (stderr)

divide.cpp: In function 'int main()':
divide.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
divide.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x[i],&g[i],&d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...