제출 #420180

#제출 시각아이디문제언어결과실행 시간메모리
420180ismoilov선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) ll delivery(int n, int k, int L, int p[]) { vector <ll> a, b; ll ans = 0, l = L; fp(i,0,n){ if(p[i] <= l-p[i]) a.push_back(p[i]*2); else b.push_back((l-p[i])*2); } sort(all(a)); sort(all(b)); ll aa = 0, bb = 0; if(a.size() % k != 0) aa = a[a.size()-1]; if(b.size() % k != 0) bb = b[b.size()-1]; if(l >= aa + bb){ int x = k-1; while(x < a.size()) ans += a[x], x += k; x = k-1; while(x < b.size()) ans += b[x], x += k; if(a.size() % k > 0) ans += a[a.size()-1]; if(b.size() % k > 0) ans += b[b.size()-1]; return ans; } else{ fp(i,0,k){ if(a.empty()){ if(!b.empty()) b.pop_back(); continue; } if(b.empty()){ if(!a.empty()) a.pop_back(); continue; } if(a.back() > b.back()) a.pop_back(); else b.pop_back(); } int x = k-1; while(x < a.size()) ans += a[x], x += k; x = k-1; while(x < b.size()) ans += b[x], x += k; if(a.size() % k > 0) ans += a[a.size()-1]; if(b.size() % k > 0) ans += b[b.size()-1]; return ans+l; } } int main() { IOS; int n, k, l; cin >> n >> k >> l; int p[n]; fp(i,0,n) cin >> p[i]; cout << delivery(n, k, l, p); }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:14:2: note: in expansion of macro 'fp'
   14 |  fp(i,0,n){
      |  ^~
boxes.cpp:29:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   while(x < a.size())
      |         ~~^~~~~~~~~~
boxes.cpp:32:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(x < b.size())
      |         ~~^~~~~~~~~~
boxes.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:41:3: note: in expansion of macro 'fp'
   41 |   fp(i,0,k){
      |   ^~
boxes.cpp:58:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   while(x < a.size())
      |         ~~^~~~~~~~~~
boxes.cpp:61:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   while(x < b.size())
      |         ~~^~~~~~~~~~
boxes.cpp: In function 'int main()':
boxes.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
boxes.cpp:77:2: note: in expansion of macro 'fp'
   77 |  fp(i,0,n)
      |  ^~
/usr/bin/ld: /tmp/ccqJwrxn.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccpMiWZp.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status