답안 #199854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199854 2020-02-03T20:52:21 Z milagrosvilla1803 Pod starim krovovima (COCI20_psk) C++11
50 / 50
6 ms 416 KB
#include <bits/stdc++.h>
using namespace std;
int n, vacios=0;
struct vasos{
    long long int tamanio;
    int indice;
};
vasos Vasos[1005];
long long int acumulado=0;
long long int aux;
bool ordenar(vasos a, vasos b){
    if(a.tamanio>b.tamanio) return true;
    return false;
}
long long int listos[1005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>aux;
        acumulado+=aux;
        cin>>Vasos[i].tamanio;
        Vasos[i].indice=i;
    }
    sort(Vasos,Vasos+n,ordenar);
    for(int i=0;i<n;i++){
        if(acumulado==0) vacios++;
        if(acumulado>=Vasos[i].tamanio){
            listos[Vasos[i].indice]=Vasos[i].tamanio;
            acumulado-=Vasos[i].tamanio;
        }else{
            listos[Vasos[i].indice]=acumulado;
            acumulado=0;
        }
    }
    cout<<vacios<<"\n";
    for(int i=0;i<n;i++){
        cout<<listos[i]<<" ";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 416 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct