Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- #define MAXN 300000
- int main() {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- int n, p, a;
- cin>>n;
- int carrello[n];
- for (a=0; a<n;a++){
- cin>>carrello[a];
- }
- int totale;
- sort(carrello, carrello + n);
- p=0;
- while (p<n) {
- p++;
- totale=totale+carrello[p];
- p++;
- totale=totale+carrello[p];
- p++;
- }
- cout<<totale;
- return 0;
- }
Add Comment
Please, Sign In to add comment