답안 #615311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
615311 2022-07-31T08:23:01 Z 조영욱(#8494) Ants and Sugar (JOI22_sugar) C++17
6 / 100
4000 ms 1112 KB
#include <bits/stdc++.h>
using namespace std;

int q,l;
typedef pair<int,int> P;
vector<P> v1;
vector<P> v2;

int main() {
    scanf("%d %d",&q,&l);
    for(int i=0;i<q;i++) {
        int t,a,x;
        scanf("%d %d %d",&t,&x,&a);
        if (t==1) {
            v1.push_back(P(x,a));
        }
        else {
            v2.push_back(P(x,a));
        }
        multiset<P> s;
        for(int j=0;j<v2.size();j++) {
            s.insert(v2[j]);
        }
        sort(v1.begin(),v1.end());
        long long ret=0;
        for(int j=0;j<v1.size();j++) {
            auto iter=s.lower_bound(P(v1[j].first-l,-1));
            int val=v1[j].second;
            vector<P> er;
            while (1) {
                if (iter==s.end()) {
                    break;
                }
                P now=(*iter);
                if (now.first>v1[j].first+l) {
                    break;
                }
                er.push_back(now);
                if (val<now.second) {
                    s.insert(P(now.first,now.second-val));
                    ret+=val;
                    break;
                }
                ret+=now.second;
                val-=now.second;
                iter++;
            }
            for(int l=0;l<er.size();l++) {
                s.erase(s.find(er[l]));
            }
        }
        printf("%lld\n",ret);
    }
    return 0;
}

Compilation message

sugar.cpp: In function 'int main()':
sugar.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j=0;j<v2.size();j++) {
      |                     ~^~~~~~~~~~
sugar.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int j=0;j<v1.size();j++) {
      |                     ~^~~~~~~~~~
sugar.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int l=0;l<er.size();l++) {
      |                         ~^~~~~~~~~~
sugar.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&q,&l);
      |     ~~~~~^~~~~~~~~~~~~~~
sugar.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d %d %d",&t,&x,&a);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 252 ms 400 KB Output is correct
7 Correct 207 ms 388 KB Output is correct
8 Correct 48 ms 340 KB Output is correct
9 Correct 44 ms 340 KB Output is correct
10 Correct 360 ms 468 KB Output is correct
11 Correct 521 ms 372 KB Output is correct
12 Correct 735 ms 460 KB Output is correct
13 Correct 737 ms 592 KB Output is correct
14 Correct 582 ms 520 KB Output is correct
15 Correct 608 ms 696 KB Output is correct
16 Correct 237 ms 436 KB Output is correct
17 Correct 197 ms 492 KB Output is correct
18 Correct 149 ms 372 KB Output is correct
19 Correct 487 ms 472 KB Output is correct
20 Correct 201 ms 368 KB Output is correct
21 Correct 946 ms 424 KB Output is correct
22 Correct 143 ms 340 KB Output is correct
23 Correct 758 ms 480 KB Output is correct
24 Correct 156 ms 412 KB Output is correct
25 Correct 720 ms 536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Execution timed out 4043 ms 1112 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Execution timed out 4086 ms 600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 252 ms 400 KB Output is correct
7 Correct 207 ms 388 KB Output is correct
8 Correct 48 ms 340 KB Output is correct
9 Correct 44 ms 340 KB Output is correct
10 Correct 360 ms 468 KB Output is correct
11 Correct 521 ms 372 KB Output is correct
12 Correct 735 ms 460 KB Output is correct
13 Correct 737 ms 592 KB Output is correct
14 Correct 582 ms 520 KB Output is correct
15 Correct 608 ms 696 KB Output is correct
16 Correct 237 ms 436 KB Output is correct
17 Correct 197 ms 492 KB Output is correct
18 Correct 149 ms 372 KB Output is correct
19 Correct 487 ms 472 KB Output is correct
20 Correct 201 ms 368 KB Output is correct
21 Correct 946 ms 424 KB Output is correct
22 Correct 143 ms 340 KB Output is correct
23 Correct 758 ms 480 KB Output is correct
24 Correct 156 ms 412 KB Output is correct
25 Correct 720 ms 536 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Execution timed out 4043 ms 1112 KB Time limit exceeded
30 Halted 0 ms 0 KB -