Submission #636971

#TimeUsernameProblemLanguageResultExecution timeMemory
636971Metal_SonicUnija (COCI17_unija)C++17
60 / 100
250 ms39508 KiB
#include <bits/stdc++.h> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; #define ll long long #define sz(x) (int)(x).size() #define all(x) x.begin() , x.end() void Sonic(string name = "") { ios_base::sync_with_stdio(false); cin.tie(nullptr); if(sz(name)){ freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } int xd[] = {0, 0, 1, -1, 1, 1, -1, -1}; int yd[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int mxn = 1e7+5; void run_test_case(){ int n;cin>>n; vector<int>ans(mxn,0); for(int i = 0; i < n; i++){ int x,y;cin>>x>>y; ans[x/2]=max(ans[x/2],y); } ll res = 0; int mx_s_f = 0; for(int i = mxn; i >= 1; i--){ res+=i*max(ans[i]-mx_s_f,0); mx_s_f = max(mx_s_f,(ans[i])); } cout<<res*2; } int main(){ Sonic(); int T = 1; //cin>>T; while(T--){ run_test_case(); } return 0; }

Compilation message (stderr)

unija.cpp: In function 'void Sonic(std::string)':
unija.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unija.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen((name+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...