답안 #890425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890425 2023-12-21T07:27:51 Z Ghulam_Junaid Sails (IOI07_sails) C++17
25 / 100
1000 ms 5828 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll N = 1e5 + 10;
ll n, p[N], initial_cost;
vector<pair<ll, ll>> vec;

int main(){
    cin >> n;

    for (ll i=0; i<n; i++){
        ll h, k;
        cin >> h >> k;

        if (h == k){
            p[0]++;
            p[h]--;
        }
        else{
            vec.push_back({h, k});
        }
    }

    initial_cost = (p[0] * (p[0] - 1)) / 2;
    for (ll i=1; i<N; i++){
        p[i] += p[i - 1];
        initial_cost += (p[i] * (p[i] - 1)) / 2;
    }

    vector<pair<ll, ll>> places;
    ll cost = initial_cost;
    for (ll i=0; i<vec.size(); i++){
        ll h = vec[i].first;
        ll k = vec[i].second;

        places.clear();
        for (ll j = h - 1; j >= 0; j--){
            places.push_back({p[j], -j});
        }
        sort(places.begin(), places.end());
    
        for (ll j=0; j<k; j++){
            ll pos = -places[j].second;
            cost += p[pos];
            p[pos]++;
        }
    }

    cout << cost << endl;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:34:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (ll i=0; i<vec.size(); i++){
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 1916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 2284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 3272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 5224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 5568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1048 ms 5828 KB Time limit exceeded
2 Halted 0 ms 0 KB -