답안 #636970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636970 2022-08-30T22:02:15 Z Metal_Sonic Unija (COCI17_unija) C++17
60 / 100
260 ms 54444 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 >= 0; 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 29 ms 39380 KB Output is correct
2 Correct 31 ms 39352 KB Output is correct
3 Correct 30 ms 39508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 39472 KB Output is correct
2 Correct 32 ms 39412 KB Output is correct
3 Correct 31 ms 39356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 39380 KB Output is correct
2 Correct 35 ms 39372 KB Output is correct
3 Correct 31 ms 39364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 39508 KB Output is correct
2 Correct 36 ms 39424 KB Output is correct
3 Correct 30 ms 39504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 54416 KB Output is correct
2 Correct 253 ms 54444 KB Output is correct
3 Correct 236 ms 54424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 39356 KB Output is correct
2 Correct 29 ms 39364 KB Output is correct
3 Correct 31 ms 39372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 39712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 40684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 43376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 235 ms 54432 KB Output isn't correct
2 Halted 0 ms 0 KB -