답안 #1053024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053024 2024-08-11T08:01:25 Z mychecksedad 사탕 분배 (IOI21_candies) C++17
3 / 100
4040 ms 2097152 KB
#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
const int N = 3e5+100;

std::vector<int> distribute_candies(std::vector<int> cc, std::vector<int> l, std::vector<int> r, std::vector<int> v) {
  vector<ll> c(all(cc));
  int n = c.size();
  int q = l.size();
  std::vector<int> s(n);

  vector<vector<int>> Q(n);
  for(int i = 0; i < q; ++i){
    for(int j = l[i]; j <= r[i]; ++j){
      Q[j].pb(v[i]);
    }
  }
  for(int i = 0; i < n; ++i){
    if(Q[i].size() == 0) continue;
    ll sum = 0;
    int f = 0;
    // for(int j = Q[i].size() - 1; j >= 0; --j){
    //   // cout << Q[i][j] << ' ';
    //   ll v = Q[i][j] + sum;
    //   if(Q[i][j] >= c[i]){
    //     ll x = c[i];
    //     for(int l = j + 1; l < Q[i].size(); ++l){
    //       x = max(0ll, min(c[i], x + Q[i][l]));
    //     }
    //     s[i] = x;
    //     f = -1;
    //     break;
    //   }
    //   else if(v >= c[i]){
    //     f = -1;
    //     int last = j;
    //     ll cur = 0;
    //     for(int l = j + 1; l < Q[i].size(); ++l){
    //       cur += Q[i][l];
    //       if(cur >= c[i]){
    //         last = l;
    //       }
    //     }
    //     ll sum = c[i];
    //     for(int l = last + 1; l < Q[i].size(); ++l){
    //       sum += Q[i][l];
    //     }
    //     // cout << "wtf" << sum << ' ';
    //     s[i] = sum;
    //     break;
    //   }else if(Q[i][j] <= -c[i]){
    //     ll x = 0;
    //     for(int l = j + 1; l < Q[i].size(); ++l){
    //       x = max(0ll, min(c[i], x + Q[i][l]));
    //     }
    //     s[i] = x;
    //     f = -1;
    //     break;
    //   }else if(v <= -c[i]){
    //     int last = j;
    //     ll cur = 0;
    //     for(int l = j + 1; l < Q[i].size(); ++l){
    //       cur += Q[i][l];
    //       if(cur <= -c[i]){
    //         last = l;
    //       }
    //     }
    //     ll sum = 0;
    //     for(int l = last + 1; l < Q[i].size(); ++l){
    //       sum += Q[i][l];
    //     }
    //     s[i] = sum;
    //     f = -1;
    //     break;
    //   }
    //   sum = v;
    // }
    if(f != -1){
      ll x = 0;
      for(int l = 0; l < Q[i].size(); ++l){
          x = max(0ll, min(c[i], x + Q[i][l]));
        }
      s[i] = x;
    }
    // if(x==-1) continue;
    // sum = 0;
    // for(int j = x; j < Q[i].size(); ++j){
    //   sum += Q[i][j];
    //   sum = max(0ll, min(sum, c[i]));
    // }
    // s[i] = sum;
  }


  return s;
}

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:87:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |       for(int l = 0; l < Q[i].size(); ++l){
      |                      ~~^~~~~~~~~~~~~
candies.cpp:27:8: warning: unused variable 'sum' [-Wunused-variable]
   27 |     ll sum = 0;
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 8 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2490 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1084 ms 572400 KB Output is correct
3 Correct 1059 ms 652628 KB Output is correct
4 Runtime error 2453 ms 2097152 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 4040 ms 1613408 KB Output is correct
4 Correct 2889 ms 1617372 KB Output is correct
5 Runtime error 2491 ms 2097152 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 8 ms 7260 KB Output is correct
6 Runtime error 2490 ms 2097152 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -