답안 #989316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989316 2024-05-28T01:12:02 Z PedroBigMan Sails (IOI07_sails) C++17
40 / 100
1000 ms 8116 KB
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro "<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cout.precision(20); 
	ll N; cin>>N; vector<pl> p; pl cur; ll H=0;
    REP(i,0,N) {cin>>cur.ff>>cur.ss; cur.ff--; p.pb(cur); H = max(H,cur.ff);}
    sort(whole(p)); vector<ll> ans(H+1,0LL);
    priority_queue<pl> q; ll lastH=-1LL; ll thisH; ll K; ll ind; ll S;
    REP(i,0,N)
    {
        thisH = p[i].ff; K = p[i].ss;
        REP(j,lastH+1,thisH+1) {q.push({0LL,j});}
        vector<pl> to_add;
        REP(j,0,K)
        {
            ind = q.top().ss; S = -(q.top().ff);
            ans[ind]++; q.pop();
            to_add.pb({-S-1LL,ind});
        }
        REP(j,0,K) {q.push(to_add[j]);}
        lastH=thisH;
    }
    ll val = 0LL; ll O;
    REP(i,0,H+1)
    {
        O = ans[i];
        val+=((O*(O-1LL))/2LL);
    }
    cout<<val<<endl;
    return 0;
}

Compilation message

sails.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization ("O3")
      | 
sails.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 7 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 234 ms 604 KB Output is correct
2 Correct 235 ms 3288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 1608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1027 ms 1804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1046 ms 2508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 8116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 3780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 4616 KB Time limit exceeded
2 Halted 0 ms 0 KB -