답안 #636971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636971 2022-08-30T22:07:04 Z Metal_Sonic Unija (COCI17_unija) C++17
60 / 100
250 ms 39508 KB
#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

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 39460 KB Output is correct
2 Correct 30 ms 39344 KB Output is correct
3 Correct 30 ms 39380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 39472 KB Output is correct
2 Correct 28 ms 39348 KB Output is correct
3 Correct 31 ms 39508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 39384 KB Output is correct
2 Correct 30 ms 39424 KB Output is correct
3 Correct 31 ms 39380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 39388 KB Output is correct
2 Correct 34 ms 39380 KB Output is correct
3 Correct 33 ms 39444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 237 ms 39380 KB Output is correct
2 Correct 233 ms 39380 KB Output is correct
3 Correct 228 ms 39380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 39380 KB Output is correct
2 Correct 31 ms 39424 KB Output is correct
3 Correct 31 ms 39448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 39392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 39352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 87 ms 39380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 39424 KB Output isn't correct
2 Halted 0 ms 0 KB -