답안 #723442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723442 2023-04-13T19:57:47 Z anton Measures (CEOI22_measures) C++17
10 / 100
1500 ms 12436 KB
#include<bits/stdc++.h>

using namespace std;

mt19937 rng(42);
#define int long long

int score(multiset<int>& s, int d){
    vector<int> v;

    for(auto e: s){
        v.push_back(e);
    }

    int score = 0;

    for(int i = 0; i<v.size(); i++){
        for(int j = i+1; j<v.size(); j++){
            score = max(score, (j-i)*d - (v[j]-v[i]));
        }
    }

    return score;
}

int my_score(multiset<int>& s, int d){
    int delta = 0;
    int score = 0;
    int rank = 0;

    for(auto e: s){
        if(delta + rank*d < e){
            delta = e -rank*d;
        }
        //cout<<"delta "<<delta<<endl;
        score = max(score, rank*d + delta - e);
        rank++;
    }

    return score;
}

void test(){
    multiset<int> s;

    int d= rng();

    for(int i = 0; i<100; i++){
        s.insert(rng()%1000 + 1000LL*1000LL*1000LL*1000LL*1000LL);
    }
    
    int s1 = my_score(s, d);
    int s2 = score(s, d);
    if(s1!=s2){
        cout<<"example: "<<d<<endl;
        /*for(auto e: s){
            cout<<e<<endl;
        }
        cout<<s1<<" "<<s2<<endl;*/
    }

}
signed main(){
    /*srand(time(NULL));
    

    for(int i = 0; i<100*1000; i++){
        test();
    }*/

    int n, m, d;
    cin>>n>>m>>d;

    multiset<int> s;

    int a;

    for(int i = 0; i<n; i++){
        cin>>a;
        s.insert(a);
    }

    int b;
    for(int i = 0; i<m; i++){
        cin>>b;
        s.insert(b);

        int s1 = score(s, d);
        cout<<s1/2;
        if(s1%2==1){
            cout<<".5";
        }
        if(i<m-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

Compilation message

Main.cpp: In function 'long long int score(std::multiset<long long int>&, long long int)':
Main.cpp:17:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i<v.size(); i++){
      |                    ~^~~~~~~~~
Main.cpp:18:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(int j = i+1; j<v.size(); j++){
      |                          ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 424 KB Output is correct
2 Correct 22 ms 428 KB Output is correct
3 Correct 22 ms 340 KB Output is correct
4 Correct 24 ms 340 KB Output is correct
5 Correct 22 ms 444 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 440 KB Output is correct
8 Correct 22 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 424 KB Output is correct
2 Correct 22 ms 428 KB Output is correct
3 Correct 22 ms 340 KB Output is correct
4 Correct 24 ms 340 KB Output is correct
5 Correct 22 ms 444 KB Output is correct
6 Correct 23 ms 360 KB Output is correct
7 Correct 23 ms 440 KB Output is correct
8 Correct 22 ms 340 KB Output is correct
9 Execution timed out 1552 ms 12436 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1555 ms 532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1555 ms 532 KB Time limit exceeded
2 Halted 0 ms 0 KB -