답안 #443348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443348 2021-07-10T11:31:54 Z leinad2 사탕 분배 (IOI21_candies) C++17
8 / 100
128 ms 13244 KB
#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>distribute_candies(vector<int>c, vector<int>l, vector<int>r, vector<int>v)
{
    int n=c.size();
    vector<long long>A;A.resize(n);
    int i, j;
    for(i=0;i<l.size();i++)
    {
        A[l[i]]+=v[i];
        if(r[i]<n-1)A[r[i]+1]-=v[i];
    }
    for(i=1;i<n;i++)A[i]+=A[i-1];
    for(i=0;i<n;i++)if(A[i]>c[i])A[i]=c[i];
    vector<int>A_int;
    for(i=0;i<n;i++)A_int.push_back(A[i]);
    return A_int;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(i=0;i<l.size();i++)
      |             ~^~~~~~~~~
candies.cpp:8:12: warning: unused variable 'j' [-Wunused-variable]
    8 |     int i, j;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 9172 KB Output is correct
2 Correct 124 ms 13244 KB Output is correct
3 Correct 124 ms 13084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -