답안 #491232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491232 2021-12-01T05:16:38 Z robell Kralj (COCI16_kralj) C++14
0 / 140
365 ms 131080 KB
/*
Problem: 
Problem Link: 
Notes: 
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define f first
#define s second
int mod=1e9+7;
inline void rv(int &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(ll &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(double &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){
        double p = 0.1;c=getchar();
        for (;c>47 && c<58;c=getchar()){n+=((c-48)*p);p/=10;}
    }
    n*=m;
}
inline void rv(float &n){
    n=0;int m=1;char c=getchar();
    if (c=='-'){m=-1; c=getchar();}
    for (;c>47 && c<58;c=getchar()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){
        double p = 0.1;c=getchar();
        for (;c>47 && c<58;c=getchar()){n+=((c-48)*p);p/=10;}
    }
    n*=m;
}
inline void rv(string &w){
    w="";char c=getchar();
    while (c!=' '&&c!='\n'&&c!=EOF){w+=c;c=getchar();}
}
inline void rv(char &c){c=getchar();}
template<typename T, typename ...Types>
void rv(T &n, Types&&... args){rv(n);rv(args...);}
void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void setIO(string f){
	freopen((f+".in").c_str(),"r",stdin);
	freopen((f+".out").c_str(),"w",stdout);
	setIO();
}
const int MN = 5e6;
int N,a[MN], p[MN], v[MN];
vector<int> l[MN];
multiset<int> str;
int main(){
	setIO();rv(N);
    for (int i=0;i<N;i++) cin >> a[i],a[i]--;
    for (int i=0;i<N;i++) cin >> p[i];
    for (int i=0;i<N;i++) cin >> v[i];
    for (int i=0;i<N;i++) l[a[i]].pb(v[i]);
    int d = N+1, ind = 0, col = 0, sind = -1;
    while (d--){
        col+=l[ind].size();
        col--;if (col==0) sind = ind;
        ind++;ind%=N; 
    }
    d=N+1;ind = sind;int games = 0;
    while (d--){
        while (!l[ind].empty()){str.insert(l[ind].back());l[ind].pop_back();}
        if (str.size()>0){
            auto itr = str.upper_bound(p[ind]);
            if (itr==str.end()) str.erase(str.begin());
            else{
                games++;str.erase(itr);
            }
        }
        ind++;ind%=N;
    }
    cout << games << "\n";
}

Compilation message

kralj.cpp: In function 'void setIO(std::string)':
kralj.cpp:65:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |  freopen((f+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kralj.cpp:66:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |  freopen((f+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 316 ms 131072 KB Execution killed with signal 11
2 Runtime error 291 ms 131072 KB Execution killed with signal 11
3 Runtime error 313 ms 131072 KB Execution killed with signal 11
4 Runtime error 302 ms 131072 KB Execution killed with signal 11
5 Runtime error 330 ms 131072 KB Execution killed with signal 11
6 Runtime error 351 ms 131072 KB Execution killed with signal 11
7 Runtime error 365 ms 131072 KB Execution killed with signal 11
8 Runtime error 266 ms 131080 KB Execution killed with signal 9
9 Runtime error 247 ms 131080 KB Execution killed with signal 9
10 Runtime error 350 ms 131072 KB Execution killed with signal 11