Submission #987419

#TimeUsernameProblemLanguageResultExecution timeMemory
987419cpdreamerSjeckanje (COCI21_sjeckanje)C++14
55 / 110
2032 ms6240 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int max_n=INT_MAX; typedef long long ll; #define pb push_back #define F first #define S second #define all(v) v.begin(),v.end() #define P pair #define V vector const long long MOD = 1000000007; // 1e9 + 7 void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } void setio(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } struct station{ int p; int c; int l; int r; }; bool custom(station a,station b) { return a.p < b.p; } void solve(){ ll n; cin>>n; ll q; cin>>q; ll A[n+1]; for(int i=1;i<=n;i++){ cin>>A[i]; } ll dp[n+1]; dp[0]=0; dp[1]=0; while(q--){ int l,r; ll v; cin>>l>>r; cin>>v; for(int i=l;i<=r;i++){ A[i]+=v; } ll maxer1=LONG_LONG_MIN; ll maxer2=LONG_LONG_MIN; for(int i=1;i<=n;i++){ maxer1=max(maxer1,dp[i-1]-A[i]); maxer2=max(maxer2,dp[i-1]+A[i]); dp[i]=max(A[i]+maxer1,-A[i]+maxer2); } cout<<dp[n]<<endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file(); solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void file()':
Main.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'void setio(std::string)':
Main.cpp:24:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...